Bootstrap Carousel图像跳跃

时间:2014-02-24 07:45:04

标签: css twitter-bootstrap twitter-bootstrap-3

我遇到了Twbs 3.1 Carousel的问题,我将图像设置为margin-left和right auto始终位于中间。当较大屏幕上的轮播滑块res> 1400px图像从左向中间跳跃时。

我需要解决它,有人可以帮助我吗?

一些代码:

<div id="myCarousel" class="carousel slide">
<!-- Indicators -->
<ol class="carousel-indicators">
    <li data-target="#myCarousel" data-slide-to="0" class="active"></li>
    <li data-target="#myCarousel" data-slide-to="1"></li>
    <li data-target="#myCarousel" data-slide-to="2"></li>
    <li data-target="#myCarousel" data-slide-to="3"></li>
    <li data-target="#myCarousel" data-slide-to="4"></li>
</ol>
<div class="carousel-inner">
    <div class="item active">
        <img src="http://placehold.it/1400X500">
        <div class="container">

            </div>
    </div>
    <div class="item">
        <img src="http://placehold.it/1400X500">
        <div class="container">

        </div>
    </div>
    <div class="item">
        <img src="http://placehold.it/1400X500">
        <div class="container">

        </div>
    </div>
    <div class="item">
        <img src="http://placehold.it/1400X500">
        <div class="container">

        </div>
    </div>
    <div class="item">
        <img src="http://placehold.it/1400X500">
        <div class="container">

        </div>
    </div>
</div>
<!-- Controls -->
<a class="left carousel-control" href="#myCarousel" data-slide="prev">
    <span class="icon-prev"></span>
</a>
<a class="right carousel-control" href="#myCarousel" data-slide="next">
    <span class="icon-next"></span>
</a>

的CSS

.item.active img{
margin-left: auto;
margin-right: auto;

}

链接到小提琴:http://jsfiddle.net/52VtD/3041/ 最诚挚的问候

3 个答案:

答案 0 :(得分:2)

只需更改

的CSS即可
.item.active img{
margin-left: auto;
margin-right: auto;
}

.carousel-inner > .item > img, .carousel-inner > .item > a > img{
    margin:auto;
}

Fiddle Demo

Fiddle Full Screen

答案 1 :(得分:2)

打电话给这堂课:

.carousel-inner .item,
.carousel-inner .item.active,
.carousel-inner .item img {
    margin: auto;
    padding: 0px;
}

谢谢Antonio(anu2x)

答案 2 :(得分:0)

在我的情况下,我不得不删除.carousel-inner {padding:5px; }。由于填充物被应用,它正在跳跃。