利用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工作流
3D几何打印人体模型ComfyUI工作流
丛林里坐着一尊佛像
一位美丽的女士在座机上讲话ComfyUI工作流
1个很漂亮的单身小女孩ComfyUI工作流
庭院,彩色玫瑰,云雾笼罩comfyui工作流
一位宇航员做在一只乌龟上在星空中游走
一朵染血的白玫瑰ComfyUI工作流
一个熙熙攘攘的市场场景,里面摆满了南瓜
猜你喜欢
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

用canvas实现画板涂鸦效果
css3动画loading效果
3d文字360度旋转
利用js+css3做一个小鱼游泳特效
css3绘制一个会动的大嘴鸟
纯CSS饼图效果
js+css3做一个灯泡开灯关灯效果






