Jump to content

CSS image rollovers


marmite

Recommended Posts

Hi, the below isn't working. I've tried several combinations, ids, classes, "", "a", "a:hover" etc. No joy.

 

The image doesn't even show.

 

Just want these images to replace each other on hover. Thanks for any help...

 

 

CSS code

# .simcards {
background-image: url(../images/bulk_sim_a.gif);
background-repeat: no-repeat;
height:26px;
width:163px;
margin:0px;
padding:0px;
}

# .simcards a{
background-image: url(../images/bulk_sim_a.gif);
background-repeat: no-repeat;
height:26px;
width:163px;
margin:0px;
padding:0px;
}

# .simcards a:hover{
background-image: url(../images/bulk_sim_b.gif);
background-repeat: no-repeat;
height:26px;
width:163px;
margin:0px;
padding:0px;
}

 

Html code

	<td width="163px"><div class="simcards">
		<a href="/index.php" ></a>
	</div></td>

Link to comment
https://forums.phpfreaks.com/topic/48288-css-image-rollovers/
Share on other sites

tables eh? euch ;)

 

using that 'markup'

<td width="163px">
<div class="simcards">
  <a href="/index.php" ></a>
</div>
</td>

 

css...

div.simcards a
{
background: transparent url(../images/bulk_sim_a.gif) no-repeat 0 0;
display: block;
height:26px;
width:163px;
margin:0px;
padding:0px;
}

div.simcards a:hover
{
background-image: url(../images/bulk_sim_b.gif);
}

 

You can help prevent the 'flicker' on the first hover (as the browser downloads the hover image for the first time) by having just the one image. put bulk_sim_a.gif and bulk_sim_b.gif into one file (one above the other so that the new image is twice as high - i will assume that would produce and image 52px in height). If you do that then all you need do is shift the back ground poistion like so...

 

div.simcards a
{
background: transparent url(../images/bulk_sim_a.gif) no-repeat 0 0;
display: block;
height:26px;
width:163px;
margin:0px;
padding:0px;
}

div.simcards a:hover
{
background-position: 0 26px;
}

Link to comment
https://forums.phpfreaks.com/topic/48288-css-image-rollovers/#findComment-236773
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.