【发布时间】:2018-04-21 17:58:15
【问题描述】:
我使用 Flexbox 创建了一个方形 div 网格来复制打印图像,并希望每个方形在页面滚动到某个点时从最高容器 div 的顶部向下滑动。尽管我知道浏览器正在获取 .scroll 功能,但这并没有触发,因为我有一个控制台日志正在运行。我一直在努力让一个 div 在这一点上滑动。 Flexbox 是超级严格还是我遗漏了什么?这是代码。
<script>
$(document).ready(function(){
$( this ).scroll(function() {
if ($(this).scrollTop() > 50){
$( "#small-twelve" ).slideDown( 5000, function(){
console.log("scrolled!")
})
};
});
});
</script>
HTML
<div class="square-container">
<div class="square-smalls-container">
<div class="small-eleven">
<div class="text">
<h3>+63.5%</h3>
<p>more computer & data processing <br/> services</p>
</div>
</div>
<div class="small-twelve" id="small-twelve">
<div class="text">
<h3>+49.0%</h3>
<p>other freight & <br/>port services</p>
</div>
</div>
</div>
<div class="long-one">
<div class="text">
<h3>+247.9%</h3>
<p>more film & television <br/>distribution services</p>
</div>
</div>
</div>
</div>
CSS
.square-smalls-container{
flex-direction: row;
display: flex;
flex: 2;
box-sizing: border-box;
position: relative;
}
.small-one, .small-two, .small-three, .small-four, .small-five, .small-six, .small-seven, .small-eight, .small-nine, .small-ten, .small-eleven, .small-twelve{
display: flex;
box-sizing: border-box;
padding: 10px;
flex-basis: 18%;
margin: 0 auto;
position: relative;
}
.small-eleven, .small-twelve{
flex: 1;
margin-left: 2%;
margin-right: 2%;
}
【问题讨论】: