如何讓絕對定位的盒子進行水平居中

一般咱們在寫輪播的時候,都會涉及到輪播圖片下方的小圓點,也就是咱們能夠選擇的小圓點要進行位置上的排版,讓它居於盒子的中間下方部分。以下圖所示:css

 

這邊就介紹一下這種是怎樣來作的。html

 

 

html代碼:spa

<div class="box">


<ul class="dian">
<li></li>
<li></li>
<li></li>
<li></li>
</ul>htm

 

</div>blog

css代碼:圖片

.box{
width: 800px;
height:500px;
background:pink;
position: relative;
}it

.dian{
width:50px;
height:10px;
margin:auto;
position: absolute;
/* top:0;*/
left:0;
right:0;
bottom:10px;io

list-style: none;
}
.dian li{
width: 5px;
height:5px;
border-radius:50%;
margin-right:10px;
float:left;
background:red;
}
.dian li:nth-of-type(1){
background:green;
}class


.dian li:nth-of-type(4){
margin-right:0;
}輪播圖

相關文章
相關標籤/搜索