CSS设置求助
各位大佬们,我在用bootstarp框架,设置了轮播图.但是我设置了css如下,但是#carousel-example-generic .item img{
/*width: 100%;*/
height: 610px;
background-size: cover;
background-position: center center;
}
效果如下,但是我设置了居中,并且模式cover,照理说应该会拉伸填满整个背景,为何却不会拉伸呢??
轮播图的html源码如下,图片路径可能需要大佬们改下,我设置了本地的.
<section>
<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" role="listbox">
<div class="item active">
<img src="../imgs/pro1.jpeg" alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="../imgs/pro2.jpeg" alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="../imgs/pro3.jpeg" alt="...">
<div class="carousel-caption">
...
</div>
</div>
<div class="item">
<img src="../imgs/pro4.jpeg" 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>
</section> 图片等比缩放导致的,换一个合适的尺寸图片,或者设置宽度100%试试 xiaoyi201321 发表于 2022-11-4 21:14
图片等比缩放导致的,换一个合适的尺寸图片,或者设置宽度100%试试
确实,设置了width是可以的. 你没有设置图片宽度啊,他原来多宽显示出来不就是多宽么。你按【f12】进开发者选项,看看你的图片的宽度【width】设置了没有 image是行内元素,要加一个display: block; 拉格朗日之都 发表于 2022-11-8 11:12
image是行内元素,要加一个display: block;
感觉大佬
页:
[1]