我的理解是 float 元素必须指定其宽度,否则可能会导致不可预测的渲染。
这是真的还是假的?
可以接受像 DIV 这样的 float 元素而不指定宽度吗?
最佳答案
不包含 float 元素的宽度是不可预测的,因为浏览器将决定 float 元素的宽度。
Theoretically, a floated element with an undefined width should shrink to the widest element within it. This could be a word, a sentence or even a single character - and results can vary from browser to browser. Source: http://css.maxdesign.com.au/floatutorial/introduction.htm
关于css - 不指定 float 元素的宽度有什么危险?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2421779/