【发布时间】:2015-03-13 22:07:24
【问题描述】:
我正在努力确保我的旋转木马尺寸在高度方面保持不变。我使用不同的图像,我知道图像大小不同,但不知道如何控制图像的高度。无论图像大小如何,我都希望我的轮播高度保持不变,那么我该如何控制呢?这是我正在使用的代码:
<div id="myCarousel" class="carousel slide" data-ride="carousel" >
<!-- 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>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner" role="listbox">
<div class="item active">
<%--<img src="img_chania.jpg" alt="Chania" width="460" height="345">--%>
<img src="img/sleep1.jpg" alt="Chania" width="460" height="345" />
<div class="carousel-caption">
<h1>Example headline.</h1>
<p>this is test </p>
</div>
</div>
<div class="item">
<%-- <img src="img_chania2.jpg" alt="Chania" width="460" height="345">--%>
<img src="img/image5.jpg" alt="Chania" width="460" height="345"/>
</div>
<div class="item">
<%--<img src="img_flower.jpg" alt="Flower" width="460" height="345">--%>
<img src="img/nature3.jpg" alt="Chania" width="460" height="145" />
<div class="carousel-caption">
<h1>Example headline.</h1>
<p>this is test </p>
</div>
</div>
<div class="item">
<%--<img src="img_flower2.jpg" alt="Flower" width="460" height="345">--%>
<img src="img/nature2.jpg" alt="Chania" width="460" height="245"/>
</div>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#myCarousel" 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="#myCarousel" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
【问题讨论】:
-
在
item类上设置高度height: 400px;- 就这么简单。您还应该包含所有相关代码 (CSS)。 -
谢谢Ruddy,这就是你的意思: 吗?我并没有真正关注..
-
我猜你几乎没有网络开发经验。你应该四处看看,因为这种事情是非常基本的。
<img src="img/image5.jpg" alt="Chania" width="460" height="400px"/>是你想要做的。如果您想将图像设置为该高度。 -
我试过还是不行
标签: html css twitter-bootstrap twitter-bootstrap-3 carousel