我有下面的html表格
<table id="label" style="width: 100%;">
<tr id="tr">
<td class='td'>
<div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>The Internet connection has</strong></div>
<iframe src="http://www.youtube.com/embed/w9DTUjrPTd0?wmode=opaque" frameborder="0" allowfullscreen width="100%" height="100%" ></iframe>
</td>
<td class='td'>
<div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Arsenal vs man city <br> 3-2 <br> 23/5/215 <br> أرسنال ضد مانشيستر سيتي</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/aDBDowU_lqc?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
</tr>
<tr id="tr">
<td class='td'>
<div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Communications' second year</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/ToACE9BTSCA?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
<td class='td'>
<div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Hello World</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/ToACE9BTSCA?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
</tr>
<tr id="tr">
<td class='td'><div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Hello World</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/ToACE9BTSCA?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
<td class='td'><div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Hello World</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/ToACE9BTSCA?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
</tr>
<tr id="tr">
<td class='td'><div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Hello World</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/ToACE9BTSCA?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
<td class='td'><div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Hello World</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/ToACE9BTSCA?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
</tr>
<tr id="tr">
<td class='td'><div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Hello World</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/ToACE9BTSCA?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
<td class='td'><div class="layout" style="position: absolute; z-index: 1; width: 485px; height: 280px; " onclick="this.style.display='none';"><strong>Hello World</strong></div>
<iframe width="100%" height="100%" src="https://www.youtube.com/embed/ToACE9BTSCA?wmode=opaque" frameborder="0" allowfullscreen></iframe>
</td>
</tr>
</table>
我不想一次渲染所有行。我一次只需要显示10行,当用户滚动时,垂直滚动条再次需要在现有的10行的基础上再添加10行,依此类推。
基本上我有所有的静态html行,我需要渲染一些,然后在scroll上添加更多。我该怎么做呢?
发布于 2015-05-31 11:16:36
好吧,因为它是一个静态页面,所以我认为您可以显示前10行,并隐藏其他行。然后使用JS/Jquery,您需要检查滚动条是否到达页面底部。你可以使用类似这样的东西:
$(window).scroll(function() {
if($(window).scrollTop() + $(window).height() == $(document).height()) {
alert("bottom!");
//shows the next 10 rows here
}
});发布于 2015-05-31 11:29:02
jQuery
$(window).scroll(function( ) {
var wScroll = $(window).scrollTop( )
if (wScroll > ($('.class').offset.Top - ($(window).height / 1.2) {
$('.class').css({'opacity': '1');
}
};CSS
.class {
opacity: 0;
transition: all 0.3s ease-in-out;
}将'.class‘更改为您想要的任何名称,并将其添加到要添加效果的元素中。此外,为了控制何时淡入,您可以更改if语句。
https://stackoverflow.com/questions/30553383
复制相似问题