1 post tagged “firefox 3”
Firefox 3 was released about a month ago as of this post. It's definitely zippier, which any user can love. And it's now Acid2-compliant, which CSS nerds love. The people who don't love it? Those of us who have to fix our code to play nice with its new rendering engine. Yeah, we can hear the CSS evangelists screaming "Well if you wrote it 'correctly' the first time..." (quotes on the fictional statement ours)
Below are got'chas we faced when Firefox 3 users started coming to our site. Sort of a CSS Firefox 3 vs Firefox 2 cheat sheet.
Floats
Widths and wrapping floats
The main problem here is that the width of the parent element (the red box in the image below and the 2nd LI in the code below) is unspecified, but its children elements are floated and do have specified widths. The parent's parent (the UL in the code below) has a width applied that forces the DIV element to wrap. This works as it should across all browsers. Where Firefox 3 gets you though is the actual width of parent element, despite the fact that the element wrapped, is equal to the total width of all its children widths. Before, in Firefox 2, the parent width would be equal to the right edge where the child elements stopped (the red box in the Before in the image below). Now, however, you get the wider parent width (the red box in the After in the image below).
Example Code:
<ul style="width: 300px;">
<li style="float: left; width: 100px;"><img .../></li>
<li style="float: left;">
<p style="width: 200px;">Today at 2:00p</p>
<div style="width: 100px;">John Doe</div>
</li>
</ul>
Solution:
For our purposes, we just specified a width for the parent element. If you were to need a parent element that required a mutable width, we're not sure how that would be handled.
Leading edge of the unfloated
Okay, the first was was a pretty specific and hairy one. This one's bound to be more common.
It's perfectly valid to have a non-float next to a float. The non-floated will sort of appear to float when it's really just wrapping around the float. The got'cha here is bounding box for the non-float is actually the same edge as the float now (the red box in the After in the image below) whereas before the bounding box's edge was equivalent to the opposite edge of the float (the red box in the Before in the image below). This means paddings and margins are not applied the way you would expect them anymore; also, if you are changing the background color of the non-float on :hover, it will put a gnarly colored box over your floated element.
Example Code:
<div style="float: left; width: 100px; height: 100px;">.</div>
<div style="padding: 0px 4px;">Text</div>
Solution:
For our purposes, we specified the non-float to be a float to allow our element to "push" off the other float and to prevent our :hover from putting a colored block over our other floated element.
Negative z-index
It's recognized now.
Our bitterness over overlapping struggles with Son of Suckerfish and our cavalcade of relative and absolute positioned elements aside, you can specifiy a negative z-index in Firefox now and it may have made all of your anchor tags unclickable. In IE, they are still clickable.
Example Code:
<a href="#hello" style="position: relative; z-index: -10">World</a>
Solution:
Set your HTML tag to be a negative z-index lower than the z-index you're using on your A tags. In the example above, a negative z-index of -20 applied to the HTML tag will make the link clickable.
Inline-block element
It's recognized now... and it's breaking your clearfix
Once we get over our kerfuffle with updating the code, we're sure we're going to be happy to finally have inline-block in Firefox at our disposal.
The problem, and the solution, here is simple. Clearfix (thanks, Position is Everything!) makes the tag it's applied to inline. It's pretty common that you had it previously applied to a block element that isn't explicitly defined as a block element in your CSS (like a DIV).
Example Code:
<div class="clearfix">I'm not on top until I'm declared a block</div>
<span>I'm on bottom</span>
Solution:
Obviously, specify your elements as blocks, but also push your clearfix CSS as high up in the file as you can, such that it doesn't override any of your block specifiers.