开发者

What unit should I use for sizing boxes inside wrapper in CSS?

开发者 https://www.devze.com 2022-12-29 16:03 出处:网络
I have a wrapper of certain width. I want开发者_StackOverflow中文版 to float 3 boxes inside that wrapper. What unit should I specify the size of the boxes in — px, em or %?This should help :)

I have a wrapper of certain width. I want开发者_StackOverflow中文版 to float 3 boxes inside that wrapper. What unit should I specify the size of the boxes in — px, em or %?


This should help :)

See Also:

Difference between em, % and px


If the wrapper has a certain (fixed?) width, then percentages would be the right way (assuming that the height of the 3 boxes may vary). Otherwise, when using em values, the 3 boxes won't fit into the wrapper side by side if the user enlarges font sizes via the browser.


Using percentages will probably give you rounding issues, so use whatever unit you used the set the "certain width" of the container (and if you used percentages for that, you'll have to live with the rounding issues).

0

精彩评论

暂无评论...
验证码 换一张
取 消