你最好的賭注是真的添加您的圖像作爲背景圖片在你的CSS,你可以做到這一點,在實際的CSS樣式表,或者只是添加樣式標記到.item
本身。然後將您的身高等添加到.carousel .item
而不是整個傳送帶本身以及背景位置和背景大小,然後將您的標記中的圖像標記完全從.item
中刪除。在以下示例中,我將!Imporatant添加到背景大小和背景位置。您可以刪除這些,如果你要只是說明在CSS樣式表中的背景,但如果你願意,你可以做somthething喜歡把它們放在HTML標記的風格標籤像
<div class="item active" style="background:url('path-to-image');"></div>
如果你這樣做你會需要保留在你的CSS重要的聲明,以便這個工作,否則沒有必要爲他們。
這裏是一個修改後的小提琴Fiddle Demo
所以你的CSS看起來像下面這樣:
.carousel .item{
width: 100%;
height: 450px;
overflow: hidden;
background-position:center !Important;
background-size:cover !important;
}
.carousel .item:nth-of-type(1){
background:url('https://pixabay.com/static/uploads/photo/2014/03/29/09/17/cat-300572_960_720.jpg')
}
.carousel .item:nth-of-type(2){
background:url('https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-349976.png')
}
.carousel .item:nth-of-type(3){
background:url('https://wallpapers.wallhaven.cc/wallpapers/full/wallhaven-80082.jpg')
}
/* Indicators list style */
.article-slide .carousel-indicators {
width: auto;
white-space: nowrap;
margin: 0;
left: 50%;
transform: translate(-50%, -50%);
}
/* Indicators list style */
.article-slide .carousel-indicators li {
border: medium none;
border-radius: 0;
float: left;
height: 54px;
margin-bottom: 5px;
margin-left: 0;
margin-right: 5px !important;
margin-top: 0;
width: 100px;
}
/* Indicators images style */
.article-slide .carousel-indicators img {
border: 2px solid #FFFFFF;
float: left;
height: 54px;
left: 0;
width: 100px;
}
/* Indicators active image style */
.article-slide .carousel-indicators .active img {
border: 2px solid #428BCA;
opacity: 0.7;
}
響應的設計通常集中在介質寬度而這又決定了高度。恩。 'img {max-width:100%;身高:自動; }' – zer00ne
您正在使用較高的高度,而不是較短的圖像,你想要的是最大高度:380px; –