实现列表内容向上滚动效果

类似上述的效果:


Paste_Image.png

上代码:

HTML:
<div class="wrp">
<div class="wrpBg"></div>
<div class="wrpTitle">
<p>
<span class="item1 item">状态</span>
<span class="item2 item">订单号</span>
<span class="item3 item">产品名称</span>
<span class="item4 item">数量</span>
<span class="item5 item">价格</span>
<span class="item6 item">日期</span>
</p>
</div>
<div class="scroll" id="scroll">
<div id="inner1">
<p>
<span class="item1 item">【订单】</span>
<span class="item2 item">12321321321</span>
<span class="item3 item">多撒多撒多撒多撒多撒多大大</span>
<span class="item4 item">1</span>
<span class="item5 item">32.26</span>
<span class="item6 item">2016-11-21</span>
</p>
</div>
</div>
</div>

</div>

注意: 直接遍历p元素就行了;

js:
function srcoll(){
var _scroll = document.getElementById("scroll"),
_inner1 = document.getElementById("inner1"),
speed = 20;
function marquee(){
if(_inner1.offsetHeight<=_scroll.scrollTop){
_scroll.scrollTop = 0
}else{
_scroll.scrollTop++;
}
}
var interval = setInterval(marquee,speed);
_scroll.onmouseover = function(){
clearInterval(interval);
}
_scroll.onmouseout = function(){
interval = setInterval(marquee,speed);
}
}
srcoll();

css:
.wrp {
position: absolute;
left: 20px;
bottom: 20px;
}
.wrp .wrpBg{
position: absolute;
/left: 20px;
bottom: 20px;
/
height: 100%;
width: 100%;
background-color: #2B2F40;
opacity: .5;
}
.wrp .wrpTitle{
padding: 10px 0;
}
.wrp .wrpTitle span{
font-weight: bold;
}
.wrp .scroll{
line-height:20px;
/border:2px dashed #666;/
height:200px;
overflow:hidden;
}
.wrp .item{
padding: 5px 0;
text-align: center;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.wrp .item1{
width: 100px;
}
.wrp .item2{
width: 200px;
}
.wrp .item3{
width: 250px;
}
.wrp .item4{
width: 100px;
}
.wrp .item5{
width: 50px;
}
.wrp .item6{
width: 150px;
}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 1. tab列表折叠效果 html: 能源系统事业部 岗位名称: 工作地点 岗位名...
    lilyping阅读 1,909评论 0 1
  • 本书介绍 你是不是对Django的学习感到迷茫?是不是对网上零星的教程感到绝望?是不是苦于没有可以迅速上手的实例而...
    阡陌3536阅读 1,339评论 0 0
  • bug修复版2017.07.11 js替代marquee实现图片无缝滚动可能大家都碰到过,当marquee中滚动的...
    巩小白阅读 706评论 0 4
  • 在我们身边,厌学的孩子越来越多。导致学生厌学的原因可谓五花八门,主要有:学习无用型、受挫型、恐惧型、抵触教师型、对...
    依心里阅读 1,570评论 0 5
  • 一、京东云 1. 东北地区首家京东云基地落户哈尔滨 4月19日,京东云与哈尔滨中关村基地战略合作签约暨京东云基地揭...
    Captain7阅读 93评论 0 0