2017-09-27 63 views
0

我有一個在大屏幕上很好的Bootstrap旋轉木馬,但如果我縮小屏幕尺寸,指標會移動到圖像下方,我完全失去標題文字。我肯定錯過了什麼。我想要在整個圖像上顯示指標和文字,就像更大的屏幕一樣。任何幫助讚賞...Bootstrap圖像旋轉木馬文本/指標在小屏幕上丟失

<div class="container" id="index"> 
    <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> 
    </ol> 

    <!-- Wrapper for slides --> 
    <div class="carousel-inner" role="listbox"> 
    <div class="item active"> 
    <div class="carousel-caption"> 
     <h3>Example headline</h3> 
     <p>Example description</p> 
     </div> 
     <img src="img/lesson8-portfolioheroimage2.jpg" alt="..."> 

    </div> 


    <div class="item"> 
     <img src="img/portfolioheroimage.jpg" alt="..."> 
     <div class="carousel-caption"> 
     <h3>Example headline</h3> 
     <p>Example description</p> 
     </div> 
    </div> 
    <div class="item"> 
     <img src="img/portfolioheroimage3.jpg" alt="..."> 
     <div class="carousel-caption"> 
     <h3>Example headline</h3> 
     <p>Example description</p> 
     </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> 
+0

這裏是我的CSS是否有幫助.carousel { \t保證金左:-15px; \t margin-right:-15px; } .carousel-inner { \t height:400px; } .carousel-caption { \t padding-bottom:450px; } .carousel-control { \t margin:200px 0; } – James

+0

https://bootsnipp.com/snippets/featured/simple-responsive-carousel這是一個Bootstrap響應旋轉木馬的例子。你有CSS和HTML代碼。 – F0XS

回答

0

這是因爲輪播中的圖像獲取調整大小時,根據其縱橫比調整大小。

刪除.carousel-control { margin: 200px 0; }.carousel-caption,而不是padding-bottombottom%並根據media queries您的要求進行調整。

而且添加該css

.carousel-inner .item{ 
    height: 100%; 
} 
.carousel-inner .item img { 
    width: 100%; 
    height: 100% !important; 
    object-fit: cover; 
} 

.carousel { margin-left: -15px; margin-right: -15px; } 
 
.carousel-inner{ height: 400px; } 
 
.carousel-caption { bottom: 30% !important; } 
 
.carousel-inner .item{ 
 
    height: 100%; 
 
} 
 
.carousel-inner .item img { 
 
    width: 100%; 
 
    height: 100% !important; 
 
    object-fit: cover; 
 
}
<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <title>Bootstrap Example</title> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
    
 
</head> 
 
<body> 
 

 
<div class="container" id="index"> 
 
    <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> 
 
    </ol> 
 

 
    <!-- Wrapper for slides --> 
 
    <div class="carousel-inner" role="listbox"> 
 
    <div class="item active"> 
 
    <div class="carousel-caption"> 
 
     <h3>Example headline</h3> 
 
     <p>Example description</p> 
 
     </div> 
 
     <img src="http://placehold.it/200x200" alt="..."> 
 

 
    </div> 
 

 

 
    <div class="item"> 
 
     <img src="http://placehold.it/200x200" alt="..."> 
 
     <div class="carousel-caption"> 
 
     <h3>Example headline</h3> 
 
     <p>Example description</p> 
 
     </div> 
 
    </div> 
 
    <div class="item"> 
 
     <img src="http://placehold.it/200x200" alt="..."> 
 
     <div class="carousel-caption"> 
 
     <h3>Example headline</h3> 
 
     <p>Example description</p> 
 
     </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> 
 
</body> 
 
</html>

+0

謝謝!似乎完美地工作。我永遠不會有我自己的!乾杯。 – James

+0

實際上,我可以問一下......這使得大屏幕上的圖像填充頁面,而我希望高度更小。試圖改變CSS,但沒有任何反應,有什麼想法? – James

+0

對不起,我不清楚你的問題。意味着您希望圖像具有100%的屏幕寬度和限制的高度? –