css - 不指定 float 元素的宽度有什么危险?

标签 css html

我的理解是 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/

相关文章:

html - Flexbox/CSS 换行顺序?包装/隐藏 flexbox div 以隐藏它的最佳方法?

javascript - 响应式可过滤组合

javascript - 动态减小文本框中的字体大小

html - 所有新的 HTML 都出现在图像后面?

html - 选择 Shiny 的输入样式(用于两个不同的选择框)

javascript - 将 body 插入 body 中

html - 输入类型文件 - 换行长文件名文本

javascript - 使用哪个 Controller 进行健康指数监控

javascript - 如何在 html 电子邮件内容中显示通过 JS 获取的月份?

html - 为什么我的 CSS 仅在放入 div 时影响 IMG?