Html DIV 的“位置”属性的默认值是多少?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16316834/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is the default value of "position" attribute of a DIV?
提问by Janak
I was just wondering what could be the default "position" attribute of a DIV ? Just the way a DIV has display property as BLOCK, what is the default property for position attribute ?
我只是想知道 DIV 的默认“位置”属性是什么?就像 DIV 的显示属性为 BLOCK 一样,位置属性的默认属性是什么?
回答by Mohit Srivastava
position: static;
The default position is static for any html element if not specified explicitly.
如果未明确指定,则任何 html 元素的默认位置都是静态的。
回答by Sirko
回答by Nitesh
Its Static. The proofof its static positioning.
它的静态。其静态定位的证明。
The HTML:
HTML:
<div class="position"> <div>
<div style="height:100px;"> </div>
<div class="noposition"> <div>
The CSS:
CSS:
div.position
{
width:100px;
height:100px;
background:red;
left:10px;
top:100px;
position:static;
}
div.noposition{
width:100px;
height:100px;
background:blue;
left:10px;
top:100px;
}
It shows that Two divs with separate classes, one without any positioning and one with a static position, positions both the Div's as static.
它表明两个具有单独类的 div,一个没有任何定位,一个具有静态位置,将两个 Div 定位为静态。
回答by Pavel
Unless it was inherited from some of its parents the default is static
除非它是从它的一些父母那里继承的,否则默认是静态的