Fixing Sub-Pixel rounding issue in a CSS Fluid Grid

后端 未结 2 1620
说谎
说谎 2021-01-05 05:51

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://jsfidd

2条回答
  •  [愿得一人]
    2021-01-05 06:06

    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.

提交回复
热议问题