top,left和postion啥关系
来源:3-1 相对和绝对定位1
流下了没有技术的眼泪
2020-03-16 17:54:50
top,left和postion啥关系
1回答
同学你好,position是定位,设置定位后,通过设置top、left等偏移量来实现定位偏移,例如:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.div1{
width:200px;
height:200px;
background-color:green;
}
.son{
width:50px;
height:50px;
position:absolute;
top:100px;
left:100px;
background-color:red;
}
</style>
</head>
<body>
<div class="son">
</div>
<div class="div1"></div>
</body>
</html>
如上所示,通过设置定位top\left的偏移量设置son的位置。
如果我的回答解决了你的疑惑,请采纳,祝学习愉快~
相似问题