以一個小例子來展示滾動提示的代碼部分:
try.html
<div id="scrollobj" >
<span class="scrollTxt">本活動將於2016年8月30日結束,如有抽獎機會,請盡快使用。              </span>
</div>
try.css
#scrollobj{
white-space:nowrap;
overflow:hidden;
width:100%;
height: 30px;
line-height: 30px;
background-color: #0553a9;
}
.scrollTxt{
width: 100%;
font-size: 16px;
color: #fff880;
}
try.js
function scroll(obj) {
var tmp = (obj.scrollLeft)++;
//當滾動條到達右邊頂端時
if (obj.scrollLeft==tmp) { obj.innerHTML += obj.innerHTML;}
//當滾動條滾動了初始內容的寬度時滾動條回到最左端
if (obj.scrollLeft>=obj.firstChild.offsetWidth) { obj.scrollLeft=0; }
}
$interval(function(){
scroll(document.getElementById('scrollobj'));
},30);