本文介绍了最好的方式来表示CSS的100%的1/3的1/3?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个大的
I have a big <div> with three little <div>'s inside of it, inline. They each have 33% width, but that causes some alignment problems because 3 * 33% != 100%. What is the best way to represent a perfect third in CSS like this? Maybe just 33.33%?
推荐答案
现在 calc =http://caniuse.com/calc>在现代浏览器中广泛支持,您可以使用:
Now that calc is widely supported among modern browsers, you can use:
#myDiv { width: calc(100% /3); }
或者,如果您的浏览器不支持:
Or you can use this as a fallback if your browser wouldn't support it:
#myDivWithFallback { width: 33.33%; width: calc(100% / 3); }
这篇关于最好的方式来表示CSS的100%的1/3的1/3?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!