将图像置于Bootstrap轮播中心?

时间:2021-05-11 20:22:16

As the title states I am having trouble getting images to center in my bootstrap carousel. The 4 images are 640x480 and keep aligning to the left of the carousel. I have uploaded my code to codepen and if anyone can help me with this problem, it'd be greatly appreciated. I have had a look at some solutions on * but I haven't been able to fix the problem.

正如标题所述,我无法将图像集中在我的引导旋转木马中。 4幅图像为640x480,并保持与旋转木马的左侧对齐。我已将代码上传到codepen,如果有人可以帮我解决这个问题,我们将不胜感激。我已经看过*上的一些解决方案,但我无法解决问题。

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

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>

1 个解决方案

#1


0  

Using Adam Azad's comment, there's working example:

使用Adam Azad的评论,有一个有效的例子:

<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>
<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 class="center-block" src="http://placehold.it/640x480?text=Slide+1">
					</div>
					<div class="item">
						<img class="center-block" src="http://placehold.it/640x480?text=Slide+2">
					</div>
					<div class="item">
						<img class="center-block" src="http://placehold.it/640x480?text=Slide+3">
					</div>
					<div class="item">
						<img class="center-block" src="http://placehold.it/640x480?text=Slide+4">
					</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 -->

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

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

#1


0  

Using Adam Azad's comment, there's working example:

使用Adam Azad的评论,有一个有效的例子:

<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'>
<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 class="center-block" src="http://placehold.it/640x480?text=Slide+1">
					</div>
					<div class="item">
						<img class="center-block" src="http://placehold.it/640x480?text=Slide+2">
					</div>
					<div class="item">
						<img class="center-block" src="http://placehold.it/640x480?text=Slide+3">
					</div>
					<div class="item">
						<img class="center-block" src="http://placehold.it/640x480?text=Slide+4">
					</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 -->

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

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