Fixing Sub-pixel Rounding Issue In A Css Fluid Grid
I'm trying to create a fluid CSS grid, it works in Firefox and IE8+ but NOT in Safari/Chrome/Opera where the sub-pixel rounding issue becomes visible: http://jsfiddle.net/bJKQ6/2/
Solution 1:
Stubbornella's OOCSS framework (links below) grids module deals with this by giving the last column the following overrides:
float: none;
overflow: hidden;
width: auto;
This allows it to occupy whatever width remains within the container.
A bit of browser-forking (IE, ptzsch…) is necessary to get the same behaviour: https://github.com/stubbornella/oocss/blob/master/core/grid/grids.csshttps://github.com/stubbornella/oocss/wiki/grids
Solution 2:
It sucks there isn't a nice option for this that will round pixels up and down for each browser, but in lieu of that, I usually do:
.nested:last-child {
float: right;
}
.nested:first-child {
float: left;
}
This will float the last child to the right so the px unalignment isn't obvious, but if it's the only element (say a div that is 33% width), then it will continue to float left.
Post a Comment for "Fixing Sub-pixel Rounding Issue In A Css Fluid Grid"