定位的用法2
<!DOCTYPE html>
<html>
<head>
<title>定位用法2</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width initial-scale=1.0">
<style type="text/css">
* {
margin:0;
padding:0;
}
body {
padding:50px;
background-color:azure;
}
.box1,.box2 {
width:200px;
height:200px;
}
.box1 {
background-color:bisque;
}
.box2 {
position:absolute; /*开启绝对定位未设置top/left时,此时top/left值为auto*/
/*top:0;
left:0;*/
background-color:cadetblue;
}
</style>
</head>
<body>
<div class="container">
<div class="box1"></div>
<div class="box2"></div>
</div>
</body>
</html>
当元素开启绝对定位·
position:obsolute
,未设置top/left值时,则top/left使用的是默认值auto