2015-07-06 58 views
0

我不知道我在做什麼錯,但我有一個引導傳送帶的奇怪問題。在幻燈片放映期間,我的物品正在晃動。你可以在下面看看它。bootstrap傳送帶不能正常工作 - 晃動物品背景

<section id="main-slider" class="no-margin"> 
    <div class="carousel slide"> 


    <div class="reservation-nav"> 
      <div class="container"> 
       <div class="row"> 
        <div class="col-md-4"> 

         <div class="btn-group btn-group-justified"> 
           <div class="btn-group"> 
            <button type="button" id="login_click" class="btn btn-default active btnvisit" data-toggle="button">Umów wizytę</button> 
           </div> 

           <div class="btn-group"> 
            <button type="button" id="register_click" class="btn btn-default btncall">Zadzwoń do nas</button> 
           </div> 
         </div> 

        </div> 
       </div> 
      </div> 
     </div>   


     <div class="carousel-inner"> 
      <div class="item active" style="background-image: url(http://lorempixel.com/output/fashion-q-c-1400-650-4.jpg)" data-ride="carousel"> 
       <div class="container"> 
        <div class="row slide-margin"> 
         <div class="col-sm-6"> 
          <div class="carousel-content"> 
          </div> 
         </div> 

        </div> 
       </div> 
      </div><!--/.item--> 

      <div class="item" style="background-image: urlhttp://lorempixel.com/output/people-q-c-1400-650-5.jpg)" data-ride="carousel"> 
       <div class="container"> 
        <div class="row slide-margin"> 
         <div class="col-sm-6"> 
          <div class="carousel-content"> 
          </div> 
         </div> 

        </div> 
       </div> 
      </div><!--/.item--> 

      <div class="item" style="background-image: url(http://lorempixel.com/output/city-q-c-1400-650-6.jpg)" data-ride="carousel"> 
       <div class="container"> 
        <div class="row slide-margin"> 
         <div class="col-sm-6"> 
          <div class="carousel-content"> 
          </div> 
         </div> 

        </div> 
       </div> 
      </div><!--/.item--> 
     </div><!--/.carousel-inner--> 
    </div><!--/.carousel--> 
    <a class="prev hidden-xs" href="#main-slider" data-slide="prev"> 
     <i class="fa fa-chevron-left"></i> 
    </a> 
    <a class="next hidden-xs" href="#main-slider" data-slide="next"> 
     <i class="fa fa-chevron-right"></i> 
    </a> 
</section><!--/#main-slider--> 

JS:

$(function(){ 
    $('#main-slider .carousel').carousel({ 
     interval: 1000, 
     cycle: 'true' 
    }); 
}); 

CSS

#main-slider { 
    position: relative; 
} 

.no-margin { 
    margin: 0; 
    padding: 0; 
} 

#main-slider .carousel .carousel-content { 
    margin-top: 150px; 
} 

#main-slider .carousel .slide-margin{ 
    margin-top: 140px; 
} 

#main-slider .carousel h2 { 
    color: #fff; 
} 

#main-slider .carousel .btn-slide { 
    padding: 8px 20px; 
    background: #b98bae; 
    color: #fff; 
    border-radius: 4px; 
    margin-top: 25px; 
    display: inline-block; 
} 

#main-slider .carousel .slider-img{ 
    text-align: right; 
    position: absolute; 
} 


#main-slider .carousel .item { 
    background-position: 50%; 
    background-repeat: no-repeat; 
    background-size: cover; 
    left: 0 !important; 
    opacity: 0; 
    top: 0; 
    position: absolute; 
    width: 100%; 
    display: block !important; 
    height: 650px!important; 
    -webkit-transition: opacity ease-in-out 500ms; 
    -moz-transition: opacity ease-in-out 500ms; 
    -o-transition: opacity ease-in-out 500ms; 
    transition: opacity ease-in-out 500ms; 
} 

#main-slider .carousel .item:first-child { 
    top: auto; 
    position: relative; 
} 

#main-slider .carousel .item.active { 
    opacity: 1; 
    -webkit-transition: opacity ease-in-out 500ms; 
    -moz-transition: opacity ease-in-out 500ms; 
    -o-transition: opacity ease-in-out 500ms; 
    transition: opacity ease-in-out 500ms; 
    z-index: 1; 
} 

#main-slider .prev, 
#main-slider .next { 
    position: absolute; 
    top: 50%; 
    background-color: #a02270; 
    color: #fff; 
    display: inline-block; 
    margin-top: -25px; 
    height: 40px; 
    line-height: 40px; 
    width: 40px; 
    line-height: 40px; 
    text-align: center; 
    border-radius: 4px; 
    z-index: 5; 
} 

#main-slider .prev:hover, 
#main-slider .next:hover { 
    background-color: #b98bae; 
} 

#main-slider .prev { 
    left: 10px; 
} 

#main-slider .next { 
    right: 10px; 
} 

#main-slider .carousel-indicators li { 
    width: 20px; 
    height: 20px; 
    background-color: #fff; 
    margin: 0 15px 0 0; 
    position: relative; 
} 

#main-slider .carousel-indicators li:after { 
    position: absolute; 
    content: ""; 
    width: 24px; 
    height: 24px; 
    border-radius: 100%; 
    background: rgba(0, 0, 0, 0); 
    border: 1px solid #FFF; 
    left: -3px; 
    top: -3px; 
} 

#main-slider .carousel-indicators .active{ 
    width: 20px; 
    height: 20px; 
    background-color: #a02270; 
    margin: 0 15px 0 0; 
    border: 1px solid #a02270; 
    position: relative; 
} 

#main-slider .carousel-indicators .active:after { 
    position: absolute; 
    content: ""; 
    width: 24px; 
    height: 24px; 
    border-radius: 100%; 
    background: #ca02270; 
    border: 1px solid #a02270; 
    left: -3px; 
    top: -3px; 
} 

#main-slider .active .animation.animated-item-1 { 
    -webkit-animation: fadeInUp 300ms linear 300ms both; 
    -moz-animation: fadeInUp 300ms linear 300ms both; 
    -o-animation: fadeInUp 300ms linear 300ms both; 
    -ms-animation: fadeInUp 300ms linear 300ms both; 
    animation: fadeInUp 300ms linear 300ms both; 
} 

#main-slider .active .animation.animated-item-2 { 
    -webkit-animation: fadeInUp 300ms linear 600ms both; 
    -moz-animation: fadeInUp 300ms linear 600ms both; 
    -o-animation: fadeInUp 300ms linear 600ms both; 
    -ms-animation: fadeInUp 300ms linear 600ms both; 
    animation: fadeInUp 300ms linear 600ms both; 
} 

#main-slider .active .animation.animated-item-3 { 
    -webkit-animation: fadeInUp 300ms linear 900ms both; 
    -moz-animation: fadeInUp 300ms linear 900ms both; 
    -o-animation: fadeInUp 300ms linear 900ms both; 
    -ms-animation: fadeInUp 300ms linear 900ms both; 
    animation: fadeInUp 300ms linear 900ms both; 
} 

#main-slider .active .animation.animated-item-4 { 
    -webkit-animation: fadeInUp 300ms linear 1200ms both; 
    -moz-animation: fadeInUp 300ms linear 1200ms both; 
    -o-animation: fadeInUp 300ms linear 1200ms both; 
    -ms-animation: fadeInUp 300ms linear 1200ms both; 
    animation: fadeInUp 300ms linear 1200ms both; 
} 

#reservation { 
    background:#fff; 
    padding:30px 0; 
    text-align:justify; 
} 

.reservation-nav { 
    position:absolute; 
    z-index:15; 
    bottom:0px; 
    width:100%; 
} 

#res-content-2 {display:none;} 

#res-content-2, #res-content-1 { 
    text-align:center; 
} 

伊夫試圖通過CSS height屬性來解決這個問題,但至今沒有成功。你有什麼想法是什麼主要問題? jsfiddle

回答

1

你的JS應該是這樣的(只能打電話#main-slider):1000也可能太快了。

$(function(){ 
    $('#main-slider').carousel({ 
     interval: 5000, 
     cycle: 'true' 
    }); 
}); 

您也在第二個背景圖片標記中忽略了URL和http之間的(

而且您還必須將onclick="$('#main-slider').carousel('prev')onclick="$('#main-slider').carousel('next')添加到您的PREV和NEXT按鈕才能激活它們。

工作修復:

$(function() { 
 
    $('#main-slider').carousel({ 
 
    interval: 5000, 
 
    cycle: 'true' 
 
    }); 
 
});
#main-slider { 
 
    position: relative; 
 
} 
 
.no-margin { 
 
    margin: 0; 
 
    padding: 0; 
 
} 
 
#main-slider .carousel .carousel-content { 
 
    margin-top: 150px; 
 
} 
 
#main-slider .carousel .slide-margin { 
 
    margin-top: 140px; 
 
} 
 
#main-slider .carousel h2 { 
 
    color: #fff; 
 
} 
 
#main-slider .carousel .btn-slide { 
 
    padding: 8px 20px; 
 
    background: #b98bae; 
 
    color: #fff; 
 
    border-radius: 4px; 
 
    margin-top: 25px; 
 
    display: inline-block; 
 
} 
 
#main-slider .carousel .slider-img { 
 
    text-align: right; 
 
    position: absolute; 
 
} 
 
#main-slider .carousel .item { 
 
    background-position: 50%; 
 
    background-repeat: no-repeat; 
 
    background-size: cover; 
 
    left: 0 !important; 
 
    opacity: 0; 
 
    top: 0; 
 
    position: absolute; 
 
    width: 100%; 
 
    display: block !important; 
 
    height: 650px!important; 
 
    -webkit-transition: opacity ease-in-out 500ms; 
 
    -moz-transition: opacity ease-in-out 500ms; 
 
    -o-transition: opacity ease-in-out 500ms; 
 
    transition: opacity ease-in-out 500ms; 
 
} 
 
#main-slider .carousel .item:first-child { 
 
    top: auto; 
 
    position: relative; 
 
} 
 
#main-slider .carousel .item.active { 
 
    opacity: 1; 
 
    -webkit-transition: opacity ease-in-out 500ms; 
 
    -moz-transition: opacity ease-in-out 500ms; 
 
    -o-transition: opacity ease-in-out 500ms; 
 
    transition: opacity ease-in-out 500ms; 
 
    z-index: 1; 
 
} 
 
#main-slider .prev, 
 
#main-slider .next { 
 
    position: absolute; 
 
    top: 50%; 
 
    background-color: #a02270; 
 
    color: #fff; 
 
    display: inline-block; 
 
    margin-top: -25px; 
 
    height: 40px; 
 
    line-height: 40px; 
 
    width: 40px; 
 
    line-height: 40px; 
 
    text-align: center; 
 
    border-radius: 4px; 
 
    z-index: 5; 
 
} 
 
#main-slider .prev:hover, 
 
#main-slider .next:hover { 
 
    background-color: #b98bae; 
 
} 
 
#main-slider .prev { 
 
    left: 10px; 
 
} 
 
#main-slider .next { 
 
    right: 10px; 
 
} 
 
#main-slider .carousel-indicators li { 
 
    width: 20px; 
 
    height: 20px; 
 
    background-color: #fff; 
 
    margin: 0 15px 0 0; 
 
    position: relative; 
 
} 
 
#main-slider .carousel-indicators li:after { 
 
    position: absolute; 
 
    content: ""; 
 
    width: 24px; 
 
    height: 24px; 
 
    border-radius: 100%; 
 
    background: rgba(0, 0, 0, 0); 
 
    border: 1px solid #FFF; 
 
    left: -3px; 
 
    top: -3px; 
 
} 
 
#main-slider .carousel-indicators .active { 
 
    width: 20px; 
 
    height: 20px; 
 
    background-color: #a02270; 
 
    margin: 0 15px 0 0; 
 
    border: 1px solid #a02270; 
 
    position: relative; 
 
} 
 
#main-slider .carousel-indicators .active:after { 
 
    position: absolute; 
 
    content: ""; 
 
    width: 24px; 
 
    height: 24px; 
 
    border-radius: 100%; 
 
    background: #ca02270; 
 
    border: 1px solid #a02270; 
 
    left: -3px; 
 
    top: -3px; 
 
} 
 
#main-slider .active .animation.animated-item-1 { 
 
    -webkit-animation: fadeInUp 300ms linear 300ms both; 
 
    -moz-animation: fadeInUp 300ms linear 300ms both; 
 
    -o-animation: fadeInUp 300ms linear 300ms both; 
 
    -ms-animation: fadeInUp 300ms linear 300ms both; 
 
    animation: fadeInUp 300ms linear 300ms both; 
 
} 
 
#main-slider .active .animation.animated-item-2 { 
 
    -webkit-animation: fadeInUp 300ms linear 600ms both; 
 
    -moz-animation: fadeInUp 300ms linear 600ms both; 
 
    -o-animation: fadeInUp 300ms linear 600ms both; 
 
    -ms-animation: fadeInUp 300ms linear 600ms both; 
 
    animation: fadeInUp 300ms linear 600ms both; 
 
} 
 
#main-slider .active .animation.animated-item-3 { 
 
    -webkit-animation: fadeInUp 300ms linear 900ms both; 
 
    -moz-animation: fadeInUp 300ms linear 900ms both; 
 
    -o-animation: fadeInUp 300ms linear 900ms both; 
 
    -ms-animation: fadeInUp 300ms linear 900ms both; 
 
    animation: fadeInUp 300ms linear 900ms both; 
 
} 
 
#main-slider .active .animation.animated-item-4 { 
 
    -webkit-animation: fadeInUp 300ms linear 1200ms both; 
 
    -moz-animation: fadeInUp 300ms linear 1200ms both; 
 
    -o-animation: fadeInUp 300ms linear 1200ms both; 
 
    -ms-animation: fadeInUp 300ms linear 1200ms both; 
 
    animation: fadeInUp 300ms linear 1200ms both; 
 
} 
 
#reservation { 
 
    background: #fff; 
 
    padding: 30px 0; 
 
    text-align: justify; 
 
} 
 
.reservation-nav { 
 
    position: absolute; 
 
    z-index: 15; 
 
    bottom: 0px; 
 
    width: 100%; 
 
} 
 
#res-content-2 { 
 
    display: none; 
 
} 
 
#res-content-2, 
 
#res-content-1 { 
 
    text-align: center; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script> 
 
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" /> 
 
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet" /> 
 
<section id="main-slider" class="no-margin"> 
 
    <div class="carousel slide"> 
 
    <div class="reservation-nav"> 
 
     <div class="container"> 
 
     <div class="row"> 
 
      <div class="col-md-4"> 
 
      <div class="btn-group btn-group-justified"> 
 
       <div class="btn-group"> 
 
       <button type="button" id="login_click" class="btn btn-default active btnvisit" data-toggle="button">Umów wizytę</button> 
 
       </div> 
 
       <div class="btn-group"> 
 
       <button type="button" id="register_click" class="btn btn-default btncall">Zadzwoń do nas</button> 
 
       </div> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
    </div> 
 
    <div class="carousel-inner"> 
 
     <div class="item active" style="background-image: url(https://ununsplash.imgix.net/photo-1416339134316-0e91dc9ded92?q=75&fm=jpg&s=883a422e10fc4149893984019f63c818)" data-ride="carousel"> 
 
     <div class="container"> 
 
      <div class="row slide-margin"> 
 
      <div class="col-sm-6"> 
 
       <div class="carousel-content"></div> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
     <!--/.item--> 
 
     <div class="item" style="background-image: url(https://ununsplash.imgix.net/photo-1416339684178-3a239570f315?q=75&fm=jpg&s=c39d9a3bf66d6566b9608a9f1f3765af)" data-ride="carousel"> 
 
     <div class="container"> 
 
      <div class="row slide-margin"> 
 
      <div class="col-sm-6"> 
 
       <div class="carousel-content"></div> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
     <!--/.item--> 
 
     <div class="item" style="background-image: url(https://ununsplash.imgix.net/photo-1416339276121-ba1dfa199912?q=75&fm=jpg&s=9bf9f2ef5be5cb5eee5255e7765cb327)" data-ride="carousel"> 
 
     <div class="container"> 
 
      <div class="row slide-margin"> 
 
      <div class="col-sm-6"> 
 
       <div class="carousel-content"></div> 
 
      </div> 
 
      </div> 
 
     </div> 
 
     </div> 
 
     <!--/.item--> 
 
    </div> 
 
    <!--/.carousel-inner--> 
 
    </div> 
 
    <!--/.carousel--> <a class="prev hidden-xs" href="#main-slider" data-slide="prev" onclick="$('#main-slider').carousel('prev')"><i class="fa fa-chevron-left"></i></a> 
 
    <a class="next hidden-xs" href="#main-slider" data-slide="next" onclick="$('#main-slider').carousel('next')"><i class="fa fa-chevron-right"></i></a> 
 

 
</section> 
 
<!--/#main-slider-->