Fixing Sub-Pixel rounding issue in a CSS Fluid Grid

江枫思渺然 提交于 2019-11-30 19:28:58

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.css https://github.com/stubbornella/oocss/wiki/grids

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!