views:

42

answers:

3

Hi,
I got a weird bug.
In my .css file I have the following rule:

.conf-view a
{
    padding-left: 10px; 
    background-image: url("images/bullet-green.gif");
    background-position: center left;
    background-repeat: no-repeat;
}

The problem is that IE somehow interprets it like this:

.conf-view A /* NOTE - this is copied from the IE-Developer tools css tab. */
    background-image : url(images/bullet-green.gif); PADDING-LEFT: 10px
    background-repeat : no-repeat
    background-position : left center

See the padding-left there?
Now the browser simply ignores the padding rule, resulting in a layout failure..

Is this a known bug? can anyone find a way around it?

Thanks a lot
Kfir

A: 

Maybe that is because the a-element normally is an inline-element. It's not common for those elements to have background-images and paddings/margins, even though it's allowed. Put display: block; in your a-style-definition. Maybe it helps you out in this situation.

EDIT

Waiting for your sample-code :)

faileN
if it will have [display:block] it will not behave as an inline element anymore which is not the desired result.. thanks anyway
kfiroo
Marcel: 1. I know the difference between element and tag - sorry for not being perfect. 2. Yes they can, but as you see it causes problems among the different browsers, which sometimes can be avoided with my suggestion, since I often used it.kfiroo: Okay I thought you wanted it to behave like an block-element, because you were putting background and padding to it.
faileN
inline-block would have been a more sensible option I think anyway...
Chris
Alright, since you're right in the end, I updated my post from tag to element. However kfiroo already stated, that it doesn't help him :/
faileN
@faileN: padding is fine on inline elements, there are only a few to which it does not apply: http://www.w3.org/TR/CSS2/box.html#propdef-padding-top
Douglas
+2  A: 

It appears to be a bug in IE Developer Tools where the display code just gobbles up the next non-background definition (sorted alphabetically, apparently) if you have background-image specified separately. Your text is not overlapping your background image on that page on either of the links, so to me it seems that the CSS is being interpreted correctly regardless; can you explain why you think that's not the case?

I have no idea how they managed to create that bug, but if you'd like for it to go away, specifying the background definitions in the shorthand seems to not exhibit that behaviour:

background:transparent url("images/bullet-green.gif") scroll no-repeat left center;

Tim Stone
thanks for your replay. in this demo it really seems like the css is interpreted correctly but on my production site the text and the bg-img overlap.. i'll try combining the bg rules into a single one
kfiroo
@Tim - nice! that worked. ill try that in the live version now.thanks a lot
kfiroo
Cool stuff. If you have a problem when you put it back into your production site, I think there must be a conflicting rule somewhere else in your stylesheet.
Tim Stone
@Time - your answer did manage to go around the developer tools bug but the original bug remained, so i had to move the 'answered' mark to @Chris
kfiroo
+1  A: 

It appears to be the diferent way it applies background images... On saving out your code and playing with the stylesheet setting the padding to 50 moved the image and the text along so its not that its ignoring the padding, just that its dealing with the positioning of the background image differently.

funnily enough faileN's suggestion wasn't far off of what I did to fix it. If you put "display: inline-block;" then that seems to work in IE7 and FF. Of course you will want to test it has no side effects elsewhere before using it.

Chris
thanks alot, i'll try that if i cant get the first solution to work
kfiroo
@Chris - thanks, your answer solved my bug.
kfiroo