我想检查 div 元素的右填充值。我使用 jquery .css() 方法:
$('div').css('padding-right');
它有效。现在我需要知道它的值(value)从何而来。它可以通过内联防御:
<div style="padding-right: 100px;">
或者它可以写在外部 css 文件中(或 <style></style>
部分):
div {
padding-right: 100px;
}
谢谢!
最佳答案
根据css()文档
Get the computed style properties
和
Note that the computed style of an element may not be the same as the value specified for that element in a style sheet. For example, computed styles of dimensions are almost always pixels, but they can be specified as em, ex, px or % in a style sheet. Different browsers may return CSS color values that are logically but not textually equal, e.g., #FFF, #ffffff, and rgb(255,255,255).
因此,无论是内联样式还是样式表,最终都是计算样式。
关于jquery - 这是内联样式还是 css 文件样式返回 jquery .css(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30504653/