DIV的“位置”属性的默认值是什么?


70

我只是想知道DIV的默认“位置”属性是什么?就像DIV将显示属性显示为BLOCK一样,position属性的默认属性是什么?

Answers:


139
position: static;

如果未明确指定,则任何html元素的默认位置都是静态的。


9
使用Chrome浏览器检查Click On the Element --> Computed --> Filter --> Show All。希望可以帮助某人。
Shaiju T

ICYMBI:一种快速的Google搜索方法-“静态定位是元素的默认定位模型。它们显示在呈现它们的页面中as part of normal HTML flow
Coty Embry

@CotyEmbry您想解释一下“ ICYMBI”对非英语母语人士意味着什么吗?我做了一个谷歌搜索,但一无所获。
ZenUML.com上的Peng '17

@XiaoPeng的首字母缩写,以防万一您可能会感兴趣
Coty Embry

12

staticposition无论使用哪个标签,始终是CSS属性的初始值。

参考文献:


6
元素的“默认”值与属性的“初始值”之间存在差异。在这种情况下,div元素没有浏览器默认值,因此它们仅采用初始值static
BoltClock

3

其静态。静态定位的证明

HTML:

<div class="position">&nbsp;<div>
    <div style="height:100px;">&nbsp;</div>
<div class="noposition">&nbsp;<div>

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;
}

它显示了两个具有单独类的div,一个没有任何位置,一个具有静态位置,将两个Div都定位为静态。


2

除非它是从其某些父级继承的,否则默认为静态


10
除非将其显式设置为position: inherit
昆汀,
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.