<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<!--
只要标签脱离标准流,标签的类型就会被强制转为 行内-块级标签
-->
<style>
.test1{
width: 300px;
height: 200px;
background-color: red;
}
.test2{
background-color: blue;
/*浮动*/
float: left;
width: 50px;
height: 30px;
}
.test3{
background-color: yellow;
/*浮动*/
float: right;
}
.test4{
background-color: brown;
}
ul li{
float: left;
}
ul li{
/*display: inline-block;*/
}
</style>
</head>
<body>
<div class="test1">
<div class="test2">左边</div>
<div class="test3">右边</div>
<div class="test4">正常的</div>
</div>
<ul>
<li>32323232</li>
<li>32323232</li>
<li>32323232</li>
<li>32323232</li>
<li>32323232</li>
</ul>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{
margin: 0;
padding: 0;
}
.main{
margin: 60px;
background-color: red;
width: 300px;
height: 200px;
/*定位*/
position: relative;
}
.test1{
width: 50px;
height:50px;
background-color: green;
position: absolute;
left: 50%;
top:50%;
/*偏移*/
transform: translate(-50%, -50%);
}
.test2{
background-color: green;
/*相对浏览器定位*/
position: fixed;
top: 0;
width: 100%;
height: 80px;
}
</style>
</head>
<body>
<!--
子绝父相
-->
<div class="main">
<div class="test1"></div>
</div>
<div class="main">
<div class="test1"></div>
</div>
<div class="main">
<div class="test1"></div>
</div>
<div class="main">
<div class="test1"></div>
</div>
<div class="main">
<div class="test1"></div>
</div>
<div class="test2">停留在浏览器的底部</div>
</body>
</html>