在项目开发中经常遇到需要实现一个滚动列表,所以讲已经实现好的代码,提炼出来,后期遇到类似需求可以照猫画虎

代码如下

1、html页面部分

<!DOCTYPE html>
<html><head><meta charset="utf-8"><title>GDP</title><link rel="stylesheet" href="${basePath}pages/gggl/layui/css/layui.css"  media="all"><link rel="stylesheet" type="text/css" href="${basePath}pages/k8/gggl/css/gdp.css"/></head><body style=""><div class="contain"><div class="content"><ul><li>行政区</li><li>产业现值(亿元)</li><li>同比增速(%)</li></ul>   <div class="list"><ul id=""></ul></div>             </div></div></body><script src="${basePath}/plugins/jquery/jquery-3.3.1.min.js"></script><script src="${basePath}/pages/k8/gggl/layui/layui.js" charset="utf-8"></script><script type="text/javascript">var basePath = '${basePath}';show();//第五个图表function show(){// 表格渲染$('.list ul').empty()let dataArr = [{"a":"黄浦区","b":439,"c":3},{"a":"徐汇区","b":439,"c":3},{"a":"长宁区","b":439,"c":3},{"a":"静安区","b":439,"c":3},{"a":"普陀区","b":439,"c":3},{"a":"虹口区","b":439,"c":3},{"a":"杨浦区","b":439,"c":3},{"a":"闵行区","b":439,"c":3},{"a":"宝山区","b":439,"c":3},{"a":"嘉定区","b":439,"c":3},{"a":"浦东新区","b":439,"c":3},{"a":"金山区","b":439,"c":3},{"a":"松江区","b":439,"c":3},{"a":"青浦区","b":439,"c":3},{"a":"奉贤区","b":439,"c":3}];var no = 1;for (var i in dataArr) {let node = '<li id="'+dataArr[i].a+'">'+'<span><div id='+no+' class="img2">'+no+'</div>'+dataArr[i].a+'</span>'+'<span title="">'+dataArr[i].b+'</span>'+'<span title=""><div class="img"></div>'+dataArr[i].c+'</span>'+'</li>'$('.list ul').append(node);$('#黄浦区').addClass('huangpu');if(no == 1){$('#1').addClass('first');}else if(no == 2){$('#2').addClass('second');}else if(no == 3){$('#3').addClass('third');}else{$('#'+no).addClass('other');}no++;}// 表格超出滚动Marquee({name: 'list',speedhq: 40})};var MyMarhq;function Marquee(opt){clearInterval(MyMarhq);let tagName = $('.'+opt.name);let tblTop = 0;let speedhq = opt.speed || 20;let outerHeight = tagName.outerHeight();let children_Height = tagName.children().height()tagName.scrollTop(0)if (children_Height > outerHeight) {tagName.children().html(tagName.children().html() + tagName.children().html())function Marqueehq(){if(parseInt(tagName.scrollTop())>= children_Height){tblTop = 0;} else {tblTop += 1;}tagName.scrollTop(tblTop)}MyMarhq = setInterval(Marqueehq,speedhq);tagName.hover(function (){clearInterval(MyMarhq);},function (){clearInterval(MyMarhq);MyMarhq = setInterval(Marqueehq,speedhq);})}}</script>
</html>

2、css样式

html,body{font-family: "微软雅黑";width: 1300px;height: 1000px;
}
.contain {width: 100%;height: 100%; color: #fff;
}
.contain > .content {width: 99%;height: 80%;margin: 0 auto;font-size: 60px;margin-top: 10px;
}
.contain > .content > ul {width: 100%;height: 100px;line-height: 100px;display: flex;align-items: center;
}
.contain > .content > ul li {float: left;text-align: center;border-bottom: 2px solid rgba(73, 186, 220, 0.2);color: #9df6f4;
}
.contain > .content .list {width: 100%;height: 100%;cursor: pointer;overflow-y: scroll;-ms-overflow-style: none;overflow: -moz-scrollbars-none;
}
.contain > .content .list::-webkit-scrollbar {width: 0px;
}
.contain > .content .list li {width: 100%;height: 100px;line-height: 100px;border-bottom: 2px solid rgba(73, 186, 220, 0.2);
}
.contain > .content .list li span {display: inline-block;height: 100%;overflow: hidden;text-overflow: ellipsis;white-space: nowrap;
}
.contain > .content > ul > li,
.contain > .content .list li span {text-align: center;
}
.contain > .content > ul > li:first-child,
.contain > .content .list li span:first-child {width: 31%;
}
.contain > .content > ul > li:nth-child(2),
.contain > .content .list li span:nth-child(2) {width: 32%;
}
.contain > .content > ul > li:nth-child(3),
.contain > .content .list li span:nth-child(3) {width: 33%;
}.img{position:relative;width:20px;height:100px;float: left;left: 135px;top:48px;background: url(../image/i_down.png) no-repeat;
}.img2{font-size:30px;position:relative;width:50px;height:100px;line-height:33px;float: left;left: 50px;top:30px;/*background: url(../image/i_first.png) no-repeat;background-size:100%;*/
}
.first{background: url(../image/i_first.png) no-repeat; background-size:100%;
}
.second{background: url(../image/i_second.png) no-repeat;   background-size:100%;
}
.third{background: url(../image/i_third.png) no-repeat; background-size:100%;
}
.other{background: url(../image/i_other.png) no-repeat; background-size:100%;
}
.huangpu{background: url(../image/huangpu_bg.png) no-repeat;    background-size:100%;
}

html的li标签结合layui实现滚动列表相关推荐

  1. php中li标签,HTML li标签是干嘛的?HTML li标签用法和属性的介绍

    HTML li标签是干嘛的?HTML li标签用法和属性的介绍都在这里,这篇文章给大家讲述的是HTML li标签的定义及属性介绍,还有html li标签如何去掉无序列表中的默认小点样式. HTML l ...

  2. 关于li标签之间的间隔如何消除!

    问题:li标签用了display:inline之后虽然成功的合并在一行,但是li标签之间出现了间距. 原因:按enter键换行之后li标签之间存在着空格,正是这些空格占据了li标签之间的空间. 解决方 ...

  3. html li标签横向排列_HTML简易的常用标签

    介绍一下常用的HTML标签,mdn里面有但是都很拗口,今天就介绍几个常用的吧. 1 首先最最最常用的div标签,这个标签就是一个空的标签,是一个闭合标签.什么是闭合标签就是一对的. 例子//<d ...

  4. HTML知识点总结之ul,ol,li标签

    HTML列表分为有序列表,无序列表和描述列表.我们常用的是有序列表(ol)与无序列表(ul). 有序列表 <ol>标签就可以定义一个有序列表,之所以称其为有序列表,是因为可以使列表具有排序 ...

  5. li标签行内元素高度及居中

    <head> <title><title> <style type="text/css">*{padding: 0px;margin ...

  6. li标签之间的空隙问题(转)

    原文地址:http://www.cnblogs.com/laogao/archive/2012/08/13/2636419.html css li 空隙问题 IE6/7的Bug:纵向排列的li中加浮动 ...

  7. 鼠标悬停在li标签上时显示一个弹框_HTML标签——列表标签

    列表使用场景: 内容相关.结构相似.样式相近的内容,根据内容的不同分为:无序列表.有序列表.定义列表 无序列表:两个标签<ul>和<li>,是嵌套关系,快捷键ul>li ...

  8. HTML li标签排列有空白间隙

    原因:由于空格和回车键造成的: 解决方法: 1.注释掉空格以及回车键造成的空格,或者去掉空格,li标签挨着写 如: <ul> <li>1</li><li> ...

  9. js ul 清缓存_JavaScript使用ul中li标签实现删除效果

    本文实例为大家分享了js使用ul中li标签实现删除效果的具体代码,供大家参考,具体内容如下 ul { list-style: none; } li { background-color: #ddd; ...

最新文章

  1. 五、DNS与bind
  2. ( Android-大神博客)
  3. ARM中的ldr指令与adr、ldr伪指令之间的区别
  4. Easytrader踩坑之旅(二)
  5. python3 协程 返回值_python asyncio 获取协程返回值和使用callback
  6. 纯CSS3技术 加载中
  7. html日期判断程序,javascript – HTML5日期验证
  8. 如何将pdf文件转换成可以编辑的文档
  9. svn和git的区别,为什么使用git?
  10. 微信小程序实现自动定位
  11. ppt矩形里面的图片怎么放大缩小_PPT5题目要求-矩形放大缩小
  12. 解决build.gradle文件报错No candidates found for method call xxxxxxx
  13. php 最常用的内置函数大全
  14. JAVA缴税_根据工资和税率计算应缴税(java)
  15. python用matplotlib画玫瑰_用Python matplotlib 怎么画风向玫瑰图 ,能给出程序的?
  16. SitePoint播客#79:即时Kool-Aid
  17. Win 10 GTX 960下 Pytorch的安装与验证
  18. 求助大佬,python类的问题
  19. 【面试题】N阶台阶,每次走一步或两步,计算共有多少种走法,并将每种走法打印出来。
  20. 【Unity】安卓adb 手机WiFi 调试安装应用

热门文章

  1. 计算机在摄影应用,计算机X线摄影在临床中的应用
  2. mac下更新自带的PHP版本到5.6或7.0
  3. PhalApi+Gearman,接口MQ异步队列任务的完整开发教程
  4. 软件·质量·管理(2)任务排期
  5. 差异表达分析(DEG)时 row.names'里不能有重复的名字 的解决方案
  6. Flutter系列之在 macOS 上安装和配置 Flutter 开发环境
  7. CoBot 库博源代码缺陷检测工具
  8. Hive权限管理,增加用户,授权
  9. 一次 WebResource.axd 异常处理经历
  10. cmap参数 plt_[转]matplotlib - plt.rcParams、matshow/cmap/坐标轴设置