这是我的代码
CSS
h2
{
position: absolute;
left: 100px;
top: 150px;
}
h1
{
position: fixed;
top: 300px;
}
HTML
<h1>
Heading for Fixed Position
<h2>
This is a heading with an absolute position</h2>
</h1>
我是CSS新手,所以正在尝试定位。我读了一些]
绝对位置元素相对于具有非静态位置的第一个父元素放置。如果找不到这样的元素,则包含块为
<html>
:如果正确,则
This is a heading with an absolute position
消息必须低于Heading for Fixed Position
,因为h1是父对象,而h2是绝对对象,因此必须相对于h1定位。如果我错了,请更正。
这里是JSFiddle链接:
这是我的代码CSS h2 {位置:绝对;左:100px;顶部:150px; } h1 {位置:固定;顶部:...
我想向您解释定位实际上是如何工作的,有4种类型
“绝对位置元素相对于具有非静态位置的第一个父元素放置。如果找不到这样的元素,则包含块为:”]