61,112
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.tu{
width: 300px;
height: 300px;
background-color: #ccc;
background-repeat: no-repeat;
background-position: center top;
position: relative;
}
.xiaobei{
width: 60px;
height: 10px;
border-radius: 25px;
background-color:rgba(255,255,255,0.4);
position: absolute;
bottom: 20px;
left: 50%;
margin-left: -30px;
}
.xiaobei li{
width: 8px;
height: 8px;
background-color: #f00;
list-style: none;
float: left;
border-radius: 100%;
margin: 1px auto;
}
</style>
</head>
<body>
<div class="tu">
<ul class="xiaobei">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>
.tu{
width: 300px;
height: 300px;
background-color: #ccc;
background-repeat: no-repeat;
background-position: center top;
position: relative;
}
.xiaobei{
width: 64px;
height: 10px;
border-radius: 25px;
background-color:rgba(255,255,255,0.4);
position: absolute;
bottom: 20px;
left: 50%;
padding: 0;
margin: 0 0 0 -32px;
}
.xiaobei li{
padding: 0;
margin: 1px 4px;
width: 8px;
height: 8px;
background-color: #f00;
list-style: none;
float: left;
border-radius: 100%;
}
float: left;方式做不到真正自动的水平居中,和平均分布,只能用margin人为调整。
要真正自动的水平居中,和平均分布,需要用伸缩盒display:flex