“自动”到底是什么? CSS height 属性的值平均值?
w3schools 表示对于身高
:
auto :浏览器计算高度。这是默认的
但是“浏览器计算高度”是什么意思?这是否意味着它只是简单地总结所包含元素的高度?对于所有浏览器来说,这总是用相同的方法计算吗?
w3schools says that for height
:
auto : The browser calculates the height. This is default
But what does “browser calculates the height” mean? Does it mean it just simply sums up the contained elements’ heights? Is this always calculated with the same method for all browser?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
你曾走过我的故事2024-12-19 10:59:10
CSS 2.1 规范和 CSS3 基本框模型规范有关于浏览器应如何计算高度的部分:
我发现将它们转化为实际应该发生的事情有点困难,而且我不能说浏览器是否真的遵循这些描述。
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
这意味着浏览器将使元素的高度足以适应其内容。
不,事情比这更复杂,但我确信这是其中的一部分。
不,通常会有很小的差异。如果您打算根据元素的高度执行计算,则应该在 JavaScript 中计算该元素的高度,不要假设它在所有浏览器上都具有相同的高度。
It means the browser will make the element's height sufficient to fit its content.
Nope, it is more complicated than that, but I'm sure that is part of it.
No, there are generally small variances. You should calculate the element's height in JavaScript if you intend to perform calculations based on it, don't assume it will have the same height on all browsers.