Forum Moderators: not2easy

Message Too Old, No Replies

FF & Safari not fully displaying a background

         

baztastic

6:44 pm on Nov 28, 2007 (gmt 0)

10+ Year Member



Hi all, I'm having some weird trouble, I've got an image with transparency, and I'm using it as a button, so that it's an <a>, and with a:link, a:visited etc I'm changing the background so that it works like onmouseover in javascript.

Problem is, in firefox it's only showing the top ~15px of the background, aligned at the bottom of the image. It works fine in IE, but not FF and safari.

You can see it at <edited>

The link, hover and active styles for the button are all aligned vertically in one image, and I tried it with 3 separate images, and that's not it.

The HTML and CSS both validate, so that's also not it..

Please help!

Here's the relevant code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>
<link REL=stylesheet HREF="spiral.css" TYPE="text/css">
</head>

<body>
<div class="links">
<a class="button_round" href="index.html"><img src="images/link-home.png" width="109" height="48" alt="Home"/></a>
</div>
</body>

</html>

div.links{
margin-right:-26px;
margin-top:0px;
height:48px;
}

a.button_round:link{
background:url(images/button_round.gif) 0px 0px no-repeat;
}

a.button_round:visited{
background:url(images/button_round.gif) 0px 0px no-repeat;
}

a.button_round:hover{
background:url(images/button_round.gif) 0px -48px no-repeat;
}

a.button_round:active{
background:url(images/button_round.gif) 0px -96px no-repeat;
}

[edited by: tedster at 7:16 pm (utc) on Nov. 28, 2007]
[edit reason] no personal urls, thanks [/edit]

rocknbil

8:42 pm on Nov 28, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well, it doesn't *directly* address the problem but I have a feeling this may fix it. Try this:
<a class="button_round" href="index.html"></a>

Note there's no img, no space.

Then add this as a general button_round selector, in addition to your :link,:hover,:active pseudo-classes:

a.button_round {
width:109px;
height:48px;
display: block;
margin:0;
padding:0;
}

<aside> You are using XML style syntax on your img tag, /> this is not valid 4.01 markup. :-) </aside>

baztastic

9:35 pm on Dec 3, 2007 (gmt 0)

10+ Year Member



hi rocknbil, thanks for your reply, yeah, that does indeed make the full background appear, but now the display:block part is making them all appear on separate lines, instead of all on the one line. Is there any way to have both display:block and all inline?

baztastic

12:34 am on Dec 17, 2007 (gmt 0)

10+ Year Member



woo, I just figured out what the problem was! Well, not quite why it was happening, but how to fix it! :-)

a.button_round {
font-size:100pt;
}

this makes the buttons right size in all browsers. I only noticed it when I took out the images, and it was only showing the alt text, and they were the exact height of the part of the background image that was showing up, and a simple font size adjust fixes it, but it won't make it bigger than the background image. It wasn't happening in IE because, even when it just shows the alt text it displays a box the size of the total image.

Hope this helps anyone who has the same problem!