2016-02-05 63 views
1

正在嘗試將旋轉木馬添加到此頁面,因此當它在移動設備上查看時,傳送帶會調整,目前它會縮小尺寸並且不可見(對不起,可能很簡單,但這是我的第一個圈地自舉)bootstrap傳送帶移動尺寸

HTML:

<!-- Carousel 
================================================== --> 
<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> 
    </ol> 
    <div class="carousel-inner" role="listbox"> 
    <div class="item active"> 
     <img class="first-slide" src="imgs/facebook%20page.jpg" alt="First slide"> 
     <div class="container"> 
     <!--<div class="carousel-caption"> 
      <h1>Example headline.</h1> 
      <p>Note: If you're viewing this page via a <code>file://</code> URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</p> 
      <p><a class="btn btn-lg btn-primary" href="#" role="button">Sign up today</a></p> 
     </div>--> 
     </div> 
    </div> 
    <div class="item"> 
     <img class="second-slide" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Second slide"> 
     <div class="container"> 
     <div class="carousel-caption"> 
      <h1>Another example headline.</h1> 
      <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> 
      <p><a class="btn btn-lg btn-primary" href="#" role="button">Learn more</a></p> 
     </div> 
     </div> 
    </div> 
    <div class="item"> 
     <img class="third-slide" src="data:image/gif;base64,R0lGODlhAQABAIAAAHd3dwAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==" alt="Third slide"> 
     <div class="container"> 
     <div class="carousel-caption"> 
      <h1>One more for good measure.</h1> 
      <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> 
      <p><a class="btn btn-lg btn-primary" href="#" role="button">Browse gallery</a></p> 
     </div> 
     </div> 
    </div> 
    </div> 
    <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><!-- /.carousel --> 


/* CUSTOMIZE THE NAVBAR 

------------------------------ -------------------- */

/* Special class on .container surrounding .navbar, used for positioning it into place. */ 
    .navbar-wrapper { 
     position: absolute; 
     top: 0; 
     right: 0; 
     left: 0; 
    z-index: 20; 
} 

    /* Flip around the padding for proper display in narrow viewports */ 
    .navbar-wrapper > .container { 
     padding-right: 0; 
     padding-left: 0; 
    } 
    .navbar-wrapper .navbar { 
    padding-right: 15px; 
    padding-left: 15px; 
} 
.navbar-wrapper .navbar .container { 
    width: auto; 
} 


/* CUSTOMIZE THE CAROUSEL 
-------------------------------------------------- */ 

/* Carousel base class */ 
.carousel { 
    height: 500px; 
    margin-bottom: 60px; 
} 
/* Since positioning the image, we need to help out the caption */ 
.carousel-caption { 
    z-index: 10; 
} 

/* Declare heights because of positioning of img element */ 
.carousel .item { 
    height: 500px; 
    background-color: #777; 
} 
.carousel-inner > .item > img { 
    position: absolute; 
    top: 0; 
    left: 0; 
    min-width: 100%; 
    height: 500px; 
} 

我可能用t來轟炸問題oo很多代碼......這樣一個noob!

在此先感謝

回答

0

所以我喜歡和引導傳送帶做的是給項目類別的百分比的pading底,而沒有給隨後的高度與這個百分比,直到你得到想要的高度發揮。這將使他們響應並調整屏幕大小。然後,不要將圖像放在旋轉木馬的內部,而是要爲每個旋轉木馬項目再添加一個類,如第一項,第二項,第三項等等。然後給你的CSS這個類的背景圖像。您可以提供項目的類別background-size:cover;background position: center;。然後,而不是在你的旋轉木馬中有一個H1標籤,我喜歡只是把一個P標籤,給它一類旋轉木馬標題,然後在你的另一個標籤給它一類旋轉木馬的描述。我不喜歡在旋轉木馬中放置h1標籤的原因是因爲您的網頁上應該只有一個h1標籤,您可以稍後指定,但如果您希望旋轉木馬中的h1標籤只是給它一類旋轉木馬標題。您可以在CSS中的samller屏幕上調整這些元素的文本大小。所以希望所有這些都有道理。

看看這個的jsfiddle和拖動顯示窗口,這樣你可以看到它resize- JSFiddle

那麼這裏就是你的HTML和CSS:

你的CSS:

#myCarousel .item{ 
    padding-bottom: 50%; 
    background-size: cover; 
    background-position: center; 
    background-repeat: no-repeat; 
    min-height: 250px; 
} 
#myCarousel .first-item{ 
    background-image: url('http://placehold.it/500x500'); 
} 
#myCarousel .second-item{ 
    background-image: url('http://placehold.it/500x500'); 
} 
#myCarousel .third-item{ 
    background-image: url('http://placehold.it/500x500'); 
} 
#myCarousel .carousel-heading{font-size: 40px;} 
@media screen and (max-width: 767px){ 
    #myCarousel .carousel-heading{font-size: 18px;} 
    #myCarousel .carousel-description{font-size: 12px;} 
    #myCarousel .btn-primary{font-size: 14px;} 
} 

,並將HTML :

<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> 
    </ol> 
    <div class="carousel-inner" role="listbox"> 
    <div class="item active first-item"> 
     <div class="container"> 
     <div class="carousel-caption"> 
      <p class="carousel-heading">Example Heading</p> 
      <p class="carousel-description">Note: If you're viewing this page via a <code>file://</code> URL, the "next" and "previous" Glyphicon buttons on the left and right might not load/display properly due to web browser security rules.</p> 
      <p><a class="btn btn-lg btn-primary" href="#" role="button">Sign up today</a></p> 
     </div> 
     </div> 
    </div> 
    <div class="item second-item"> 
     <div class="container"> 
     <div class="carousel-caption"> 
      <p class="carousel-heading">Example Heading</p> 
      <p class="carousel-description">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> 
      <p><a class="btn btn-lg btn-primary" href="#" role="button">Learn more</a></p> 
     </div> 
     </div> 
    </div> 
    <div class="item third-item"> 
     <div class="container"> 
     <div class="carousel-caption"> 
      <p class="carousel-heading">Example Heading</p> 
      <p class="carousel-description">Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p> 
      <p><a class="btn btn-lg btn-primary" href="#" role="button">Browse gallery</a></p> 
     </div> 
     </div> 
    </div> 
    </div> 
    <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><!-- /.carousel -->