我正在尝试将Bootstrap Carousel指示器对齐到垂直位置并将其定位在页面右侧。
正如您在下面的演示中看到的那样(请查看Bootply上的附加链接,因为我不确定为什么指标在JSFIDDLE看起来仍然是水平的)
正如您从演示中看到的那样,我在right: 5%;
上设置了.carousel-indicators
,但您的渲染几乎就在旋转木马的中间!你能告诉我我做错了吗?
.carousel-indicators {
background-color:#000;
position: absolute;
bottom: 200px;
z-index: 15;
width: 30px;
margin-left: 20px;
list-style: none;
text-align: center;
right: 5%;
}
.carousel-indicators li{
display: block;
width: 10px;
height: 10px;
margin-bottom: 10px;
}
.carousel-indicators .active {
width: 12px;
height: 12px;
margin-bottom: 10px;
background-color: #fff;
}

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
<li data-target="#carousel-example-generic" data-slide-to="1"></li>
<li data-target="#carousel-example-generic" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<img src="http://placehold.it/1920x400/333/333" alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="http://placehold.it/1920x400/333333/333333" alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="http://placehold.it/1920x400/333/333" alt="...">
<div class="carousel-caption">
...
</div>
</div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
&#13;
答案 0 :(得分:2)
在bootstrap css中将左侧组件设置为50%。你需要覆盖它。 给你的指标留下95%应该解决你的问题。
left:95%
答案 1 :(得分:1)
设置left:inherit
因为lib具有必须覆盖的默认设置。