利用html+css+javascript实现表格内容向上自动滚动轮播,下面web建站小编给大家介绍一下具体实现代码!
html代码:
<div id="box">
<table id="table">
<thead class="table-thead">
<tr>
<th>姓名</th>
<th>城市</th>
<th>数量</th>
</tr>
</thead>
<tbody class="table-tbody">
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
<tr>
<td>王小米</td>
<td>哈尔滨</td>
<td>100</td>
</tr>
</tbody>
</table>
</div>
css代码:
* {
margin:0px;
padding:0px;
}
.table-tbody td {
width:180px;
text-align:center;
}
table tr {
height:40px;
}
#box {
height:200px;
width:720px;
overflow:hidden;
}
.table-thead {
position:sticky;
top:0;
background-color:#eee;
}
javascript代码:
window.onload = function() {
var box = document.getElementById("box");
var table = document.getElementById("table");
box.scrollTop = 0;
var timer = null;
timer = setInterval(function() {
box.scrollTop++;
if (box.scrollTop > box.offsetHeight) {
box.scrollTop = 0;
}
}, 30);
box.onmouseover = function() {
clearInterval(timer)
}
box.onmouseout = function() {
timer = setInterval(function() {
box.scrollTop++;
if (box.scrollTop > box.offsetHeight) {
box.scrollTop = 0;
}
}, 30)
};
}
Shell命令:宝塔如何在指定文件夹下面批量复制指定文件重新命名
上面是“利用javascript实现表格内容向上自动滚动轮播”的全面内容,想了解更多关于 前端知识 内容,请继续关注web建站教程。
当前网址:https://ipkd.cn/webs_13715.html
workflows工作流
梦幻中的一只猫咪ComfyUI工作流
池塘边的大熊猫ComfyUI工作流
一只在森林里漫步的麋鹿ComfyUI工作流
一个闪闪发光的金属球ComfyUI工作流
冬天的严寒里红梅枝上停留着一只鸟
一只张大嘴巴露出锋利的牙齿正在咆哮的雪豹
一个女人站在海边的岩石上,飞来一只鸟
一张精心制作的熊岛复古地图ComfyUI工作流
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

如何利用svg做一个有趣的loading动画加载
canvas黑洞漩涡(canvas+js)
纯css翻书效果
css3卡片动态滑动效果
js实现table表格动态新增行和列表
canvas空间文本射线
js实现下雪特效











