首页 > 代码库 > CSS的定位
CSS的定位
CSS position 属性
position的属性值有4个,分别是:
1.static(静态定位)
2.relative(相对定位)
3.absolute(绝对定位)
4.fixed(固定定位)
最常见的就是relative和absolute结合起来一起用,将所在的父级设置为relative,子级设置为absolute,将所在的父级当做坐标的0,0点;如:
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
<style>
.box{
width: 400px;
height: 400px;
background-color: darkgoldenrod;
position: relative;
}
.box1{
width: 100px;
height: 100px;
background-color: darkblue;
position: absolute;
left: 100px;
top: 100px;
}
</style>
</head>
<body>
<div class="box">
<div class="box1"></div>
</div>
</body>
</html>
CSS的定位
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。