“自动”值对CSS高度属性意味着什么? [英] What exactly does the 'auto' value mean for the CSS height property?

查看:105
本文介绍了“自动”值对CSS高度属性意味着什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

w3schools表示,对于身高

w3schools says that for height:


auto:浏览器计算高度。这是默认值

但浏览器计算高度是什么意思?这是否意味着它只是简单地总结了包含的元素的高度?这对于所有的浏览器来说总是用相同的方法进行计算吗?

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?

推荐答案


这是什么意思? >浏览器计算高度?

这意味着浏览器会让元素的高度足以适应其内容。

It means the browser will make the element's height sufficient to fit its content.


这是否意味着它只是简单地总结了包含的元素高度,如果它们彼此相连?

Does it mean it just simply sums up the contained elements heights if they are up on each other?

不,它比这更复杂,但我相信这是它的一部分。

Nope, it is more complicated than that, but I'm sure that is part of it.


这是否总是用所有浏览器的方法都是一样的吗?

Is this always calculated with the same method for all browsers?

不,通常有很小的差异。如果您打算根据它进行计算,则应该在JavaScript中计算元素的高度,不要以为它在所有浏览器上都具有相同的高度。

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.

这篇关于“自动”值对CSS高度属性意味着什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆