2016-01-16 40 views
1

我有一個工作正常的傳送帶。但是,當我嘗試降低傳送帶的高度時,整個圖像不會顯示在傳送帶上(桌面上)。在移動設備上它工作正常。傳送帶不在桌面上顯示圖像

我不希望傳送帶覆蓋整個頁面。 請在全屏幕中查看輸出。

實施例:

@import url('https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'); 
 
@import url('https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/themes/smoothness/jquery-ui.css'); 
 
#carousel-example-generic .carousel-inner .item { 
 
    padding-bottom: 50%; 
 
} 
 
#carousel-example-generic .carousel-inner .first-item { 
 
    height: 100%; 
 
    width: 100%; 
 
    background: url('http://p1.pichost.me/i/13/1359503.jpg'); 
 
    background-size: cover; 
 
    background-position: center; 
 
} 
 
#carousel-example-generic .carousel-inner .second-item { 
 
    height: 100%; 
 
    width: 100%; 
 
    background: url('http://all4desktop.com/data_images/1920%20x%201200/4211692-abstract-color-background-picture-8016.jpg'); 
 
    background-size: cover; 
 
    background-position: center; 
 
} 
 
#carousel-example-generic .carousel-inner .third-item { 
 
    height: 100%; 
 
    width: 100%; 
 
    background: url('http://www.macwallhd.com/wp-content/Wallpapers/Abstract/Mac%20Wallpaper%20Spin%20The%20Apple%20Circle-575024442.jpeg'); 
 
    background-size: cover; 
 
    background-position: center; 
 
}
<script src="http://code.jquery.com/jquery-latest.min.js"></script> 
 
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.11.4/jquery-ui.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
 

 
<div id="carousel-example-generic" class="carousel slide slid" data-ride="carousel"> 
 
    <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> 
 
    <div class="carousel-inner" role="listbox"> 
 
    <div class="item active first-item"> 
 
     <div class="carousel-caption"> 
 
     ... 
 
     </div> 
 
    </div> 
 
    <div class="item second-item"> 
 
     <div class="carousel-caption"> 
 
     ... 
 
     </div> 
 
    </div> 
 
    <div class="item third-item"> 
 
     <div class="carousel-caption"> 
 
     ... 
 
     </div> 
 
    </div> 
 
    </div> 
 
    <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

它佔用全屏幕。你不希望這種情況發生或什麼? –

+0

@shannon哈哈。看起來問題已經解決了。在大屏幕時,他不希望它佔據全寬。 –

回答

1

添加以下CSS設置一個max-width,之後是寬度與高度成比例的限制:

#carousel-example-generic { 
    max-width: 960px; 
    margin: auto; 
} 

輸出:http://output.jsbin.com/revecireyu/1

+0

感謝您回覆我的帖子。我嘗試了您提出的更改。但我希望寬度爲100%,我不希望高度爲100%。但如果我改變寬度,即使高度改變。 –

+0

@SriHarsha這就是爲什麼它與圖像兄弟成正比! –

+1

我已經理解了,謝謝你的幫助。 –