在 CSS 中,我将标签的高度设置为 19px。但是,当我使用 getOffsetHeight()
方法检查标签的高度时,我有时收到 18 有时收到 20(从来没有收到 19)。标签中的文本在每次 getOffsetHeight
调用之间发生变化。
我不确定是什么问题。
最佳答案
设置 height
CSS 属性不包括填充、边框或边距。来自 GWT javadoc对于 getOffsetHeight()
:
Gets the object's offset height in pixels. This is the total height of the object, including decorations such as border and padding, but not margin.
所以您看到的值增加是因为 getOffsetHeight()
返回了 Label
的总高度,包括边框和填充。
关于css - GWT:标签 getOffsetHeight() 值与 CSS 值不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14003779/