圆点无法margin auto自动居中

圆点无法margin auto自动居中

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
//css
.main{
  width1200px;
  height460px;
  positionrelative;
}
.img{
  width999999px;
  height460px;
  positionabsolute;
  top0;
  left0;
 
}
.img img{
  floatleft;
}
.index{
  positionabsolute;
  bottom5px;
  text-aligncenter;
  margin:0 auto;
  width75px;
 
}
.index ul{
  list-style-typenone;
  overflowhidden;
  padding0;
}
.index li{
  floatleft;
  margin-left5px;
  width10px;
  height10px;
  border-radius: 50%;
  background-color: rgba(100,100,100,0.3);
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<!DOCTYPE html>
<html dir="ltr">
  <head>
    <meta charset="utf-8">
    <title>jq轮播</title>
    <link rel="stylesheet" href="./css/master.css">
  </head>
  <body>
    <div class="main">
      <div class="img">
        <img src="./img/1.jpg" alt="">
        <img src="img/2.jpg" alt="">
        <img src="img/3.jpg" alt="">
        <img src="img/4.jpg" alt="">
        <img src="img/5.jpg" alt="">
 
      </div>
      <div class="index">
        <ul>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
          <li></li>
        </ul>
      </div>
      <div class="left">
        <img src="" alt="">
      </div>
      <div class="right">
        <img src="" alt="">
      </div>
 
    </div>
    <script src="https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></script>
    <script src="./js/a.js"></script>
  </body>
</html>


正在回答

登陆购买课程后可参与讨论,去登陆

1回答

因为圆点整体设置定位 ,所以margin:0 auto不能实现居中了 . 建议如下 修改:

http://img1.sycdn.imooc.com//climg/5b861c5e0001db9e04040236.jpg

希望能够帮到你 ,祝学习愉快 ,望采纳

  • 慕九州8427191 提问者 #1
    是用了position' 就无法使用margin auto吗 为什么
    2018-08-29 15:25:50
  • 好帮手慕夭夭 回复 提问者 慕九州8427191 #2
    是的哦 , margin :0 auto根据父元素计算 , 元素设置绝对定位后脱离文档流 , 需要用left ,right, top ,bottom去设置位置 .
    2018-08-29 15:34:16
问题已解决,确定采纳
还有疑问,暂不采纳

恭喜解决一个难题,获得1积分~

来为老师/同学的回答评分吧

0 星
请稍等 ...
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号

在线咨询

领取优惠

免费试听

领取大纲

扫描二维码,添加
你的专属老师
插入代码