2016-08-16 2 views
1

Как говорится в заголовке, у меня возникли проблемы с получением изображений в центре моей каретки. 4 изображения 640x480 и выравнивание слева от карусели. Я загрузил свой код в кодировщик, и если кто-то может помочь мне с этой проблемой, мы будем очень благодарны. Я рассмотрел некоторые решения в stackoverflow, но я не смог исправить эту проблему.Центрирование изображений в карусели Bootstrap?

http://codepen.io/omfggrenade/pen/wWOKER

<body> 
<!-- Main jumbotron for a primary marketing message or call to action --> 
<div class="jumbotron"> 
    <div class="container"> 
    <h1 align="center">The Big Cats</h1> 
    </div> 
</div> 
<div class="container"> 
    <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> 
      <li data-target="#carousel-example-generic" data-slide-to="3"></li> 
     </ol> 
     <!-- Wrapper for slides --> 
     <div class="carousel-inner"> 
      <div class="item active"> 
       <img src="http://placehold.it/640x480"> 
      </div> 
      <div class="item"> 
       <img src="http://placehold.it/640x480"> 
      </div> 
      <div class="item"> 
       <img src="http://placehold.it/640x480"> 
      </div> 
      <div class="item"> 
       <img src="http://placehold.it/640x480"> 
      </div> 
     </div> 
     <!-- Controls --> 
     <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> 
      <span class="glyphicon glyphicon-chevron-left"></span> 
     </a> 
     <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> 
      <span class="glyphicon glyphicon-chevron-right"></span> 
     </a> 
     </div> 
</div> <!-- /container --> 
<script src="js/jquery.min.js"></script> 
<script src="js/bootstrap.min.js"></script> 
</body> 
</html> 
+0

Try класс '= "Центр-блок"' на 'img' –

+0

Я попытался добавить class = "center-block" к моему коду, и он не выглядит так, как будто он влияет на что-либо. Я начинаю думать, что этот код проклят :( –

ответ

0

Используя комментарий Адама Азада, там рабочий пример:

<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'> 
 
<div class="container"> 
 
\t \t <div id="carousel-example-generic" class="carousel slide" data-ride="carousel"> 
 
\t \t \t \t <!-- Indicators --> 
 
\t \t \t \t <ol class="carousel-indicators"> 
 
\t \t \t \t \t <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li> 
 
\t \t \t \t \t <li data-target="#carousel-example-generic" data-slide-to="1"></li> 
 
\t \t \t \t \t <li data-target="#carousel-example-generic" data-slide-to="2"></li> 
 
\t \t \t \t \t <li data-target="#carousel-example-generic" data-slide-to="3"></li> 
 
\t \t \t \t </ol> 
 
\t \t \t \t <!-- Wrapper for slides --> 
 
\t \t \t \t <div class="carousel-inner"> 
 
\t \t \t \t \t <div class="item active"> 
 
\t \t \t \t \t \t <img class="center-block" src="http://placehold.it/640x480?text=Slide+1"> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t <div class="item"> 
 
\t \t \t \t \t \t <img class="center-block" src="http://placehold.it/640x480?text=Slide+2"> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t <div class="item"> 
 
\t \t \t \t \t \t <img class="center-block" src="http://placehold.it/640x480?text=Slide+3"> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t \t <div class="item"> 
 
\t \t \t \t \t \t <img class="center-block" src="http://placehold.it/640x480?text=Slide+4"> 
 
\t \t \t \t \t </div> 
 
\t \t \t \t </div> 
 
\t \t \t \t <!-- Controls --> 
 
\t \t \t \t <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev"> 
 
\t \t \t \t \t <span class="glyphicon glyphicon-chevron-left"></span> 
 
\t \t \t \t </a> 
 
\t \t \t \t <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next"> 
 
\t \t \t \t \t <span class="glyphicon glyphicon-chevron-right"></span> 
 
\t \t \t \t </a> 
 
\t </div> 
 
</div> <!-- /container -->

Codepen: http://codepen.io/bra1N/pen/QEoyLL

+0

Обратите внимание, что это будет просто центрировать изображение по горизонтали. –

+0

Я не знаю, изменилось ли что-то, кроме класса = "center-block", но код работает. добавлен фрагмент кода, он отказался работать. После того, как я скопировал и вставил ваш пример, он работает! Спасибо за ваш вклад! –

Смежные вопросы