HTML之相对定位position,relative 用通俗的话讲就是把一个div块固定于另一个div块上,即覆盖
以上一篇发文绝对定位为参考
https://blog.youkuaiyun.com/qq_44973159/article/details/90812832
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>fixed</title>
</head>
<style type="text/css">
#id1{
width: 400px;
height: 50px;
background: springgreen;
font-family: 华文行楷;
font-size: 25px;
float: left;
position: relative;<--修改为相对定位-->
margin-left: 50px;<--设置好边距-->
margin-top: 40px;<--设置好边距-->
}
.div1{
width: 500px;
height: 900px;
background: darkturquoise;
}
.div2{
width: 500px;
height: 900px;
background: bisque;
}
</style>
<body>
<div id="id1">relative相对定位</div>
<div class="div1"></div>
<div class="div2"></div>
</body>
</html>
最开始未滚动时
滚动后绿条也会滚动
可以与绝对定位做比较,