2016-08-21 33 views
0

使用Bootstrap或CSS3,除了逐漸出現以外,如何讓用戶向下滾動時向上滑動div元素?當div出現時CSS3轉換

@-webkit-keyframes easein 
 
{ 
 
    0% {opacity:0}; 
 
    100% {opacity:1}; 
 
} 
 
@keyframes easein 
 
{ 
 
    0% {opacity:0}; 
 
    100% {opacity:1}; 
 
} 
 
.ndd-easein 
 
{ 
 
    -webkit-animation-name:easein; /* Chrome, Safari, Opera */ 
 
    -webkit-animation-duration:1.5s; /* Chrome, Safari, Opera */ 
 
    animation-name:easein; 
 
    animation-duration:1.5s; 
 
    animation-timing-function:ease-in; 
 
}

回答

0

這個插件做了很好的工作:scrollrevealjs,這是通過jQuery的例子存檔:

$(document).ready(function() { 
 
    /* Every time the window is scrolled ... */ 
 
    $(window).scroll(function() { 
 
    /* Check the location of each desired element */ 
 
    $('.hideme').each(function(i) { 
 
     var bottom_of_object = $(this).offset().top + $(this).outerHeight(); 
 
     var bottom_of_window = $(window).scrollTop() + $(window).height(); 
 
     /* If the object is completely visible in the window, fade it it */ 
 
     if (bottom_of_window > bottom_of_object) { 
 
     $(this).animate({ 
 
      'opacity': '1' 
 
     }, 500); 
 
     } 
 
    }); 
 
    }); 
 
});
#container { 
 
    height: 2000px; 
 
} 
 

 
#container DIV { 
 
    margin: 50px; 
 
    padding: 50px; 
 
    background-color: lightgreen; 
 
} 
 

 
.hideme { 
 
    opacity: 0; 
 
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<div id="container"> 
 
    <div class="hideme">Fade In</div> 
 
    <div class="hideme">Fade In</div> 
 
    <div class="hideme">Fade In</div> 
 
    <div class="hideme">Fade In</div> 
 
    <div class="hideme">Fade In</div> 
 
    <div class="hideme">Fade In</div> 
 
    <div class="hideme">Fade In</div> 
 
</div>

+0

對不起,是不是有任何解決方案通過Bootstrap? – AgitatedMind

+0

所有bootstrap JavaScript插件都在http://getbootstrap.com/javascript/中列出,它們不會通過CSS3 –

+0

@AgitatedMind執行此淡出滾動操作,您需要查找Javascript或Jquery not bootstrap –