954,604 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

CSS Sprite Button

Hi,

I am trying to create a button using css sprite.

buttonnav.css

a.button {
	background: url(../images/buttonnav.png) no-repeat 0 0;
	width: 100px;
	height: 50px;
	display: block;
	text-indent: -9999px;
}


a.button:hover { background-position: 0 -2px; }

a.button:active { background-position: 0 -8px; }

index.php

<div id="button">Button</div>


I do not see the button image, only the text "button". What's wrong with my code ?


Thanks.

davy_yg
Posting Whiz
377 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

You refer to a.button in your CSS when the id is called button. You would access that is the CSS with #button.

hericles
Practically a Posting Shark
823 posts since Nov 2007
Reputation Points: 136
Solved Threads: 169
 

Try changing the code in your HTML file to

<div class="button">Button</div>


and in your CSS file,

.button{  }


Otherwise, follow what hericles has mentioned above to fix your problem.

rotten69
Posting Whiz
346 posts since May 2011
Reputation Points: 3
Solved Threads: 16
 

I change it to:

sidebanner.css

@charset "utf-8";
/* CSS Document */

#button {
	background: url(../images/buttonnav.png) no-repeat 0 0;
	width: 100px;
	height: 50px;
	display: block;
	text-indent: -9999px;
}


#button a:hover { background-position: 0 -2px; }

#button a:active { background-position: 0 -8px; }


slideshow2.php

<div id="button">Button</div>


still the image does not appear yet. The image is this big:


buttonnav.png
I-I
I-I

davy_yg
Posting Whiz
377 posts since May 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You