没有其他属性的静态和相对总是在同一位置呈现吗?
我知道具有相对位置的元素将用作其内部具有绝对定位的元素的固定元素,并且使用相对位置我可以推动元素,但是如果我不添加任何其他属性,具有这种 style: 的元素是否
.element1 {
position: relative;
}
总是与具有以下样式的元素呈现相同:
.element2 {
position: static;
}
如果不是,它们什么时候会有所不同?
I understand that an element with position relative will be used as the fixed for elements inside it with positioning absolute, and that with relative I can push the element around, but if I don't add any other attributes, will an element with this style:
.element1 {
position: relative;
}
always render the same as one with:
.element2 {
position: static;
}
If not, when would they differ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它看起来会是一样的,因为你是说我要给你定位,而不是指示在哪里定位,所以除非你定位它否则它会保持在同一个地方。
It will appear same because you are saying that I am going to position you and not instructing where to position so unless you position it will remain at same place.
我找到了一个专门处理这个主题的维基条目:
http://www.w3.org/wiki/ CSS_static_and_relative_positioning
根据这一点,如果还有一些定位(正如您所说)以及周围的其他元素,那么它只会与您的相对定位元素重叠。
I've found a wiki entry dealing exactly with this topic:
http://www.w3.org/wiki/CSS_static_and_relative_positioning
According to this, it makes only a difference, if there is also some positioning, as you said, and other elements around, which might then be overlapped by your relative positioned one.