国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

div+css+js實(shí)現(xiàn)無縫滾動類似marquee無縫滾動兼容firefox

2019-11-20 22:21:02
字體:
供稿:網(wǎng)友
div+css+javascript 實(shí)現(xiàn)無縫滾動,marquee無縫滾動,無縫滾動,兼容firefox

用marquee實(shí)現(xiàn)首尾相連循環(huán)滾動效果(僅IE):
復(fù)制代碼 代碼如下:

<marquee behavior="scroll" contenteditable="true" onstart="this.firstChild.innerHTML+=this.firstChild.innerHTML;" scrollamount="3" width="100" onmouseover="this.stop();" onmouseout="this.start();">
這里是要滾動的內(nèi)容
</marquee>

用div+css+javascript實(shí)現(xiàn)首尾相連循環(huán)滾動效果(兼容firefox):
復(fù)制代碼 代碼如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>div+css+javascript 實(shí)現(xiàn)無縫滾動,marquee無縫滾動,無縫滾動,兼容firefox</title>
<style type="text/css">
#scrollobj {
white-space: nowrap;
overflow: hidden;
width: 500px;
}
</style>
</head>
<body>
<div id="scrollobj" onmouseover="javascript:_stop();" onmouseout="javascript:_start();">
這里是要滾動的內(nèi)容
</div>
<script language="javascript" type="text/javascript">
<!--
function scroll(obj) {

/*往左*/
var tmp = (obj.scrollLeft)++;
//當(dāng)滾動條到達(dá)右邊頂端時
if (obj.scrollLeft == tmp) {
obj.innerHTML += obj.innerHTML;
}
//當(dāng)滾動條滾動了初始內(nèi)容的寬度時滾動條回到最左端
if (obj.scrollLeft >= obj.firstChild.offsetWidth) {
obj.scrollLeft = 0;
}

/*往上*/
//var tmp = (obj.scrollTop)++;
//if (obj.scrollTop == tmp) {
// obj.innerHTML += obj.innerHTML;
//}
//if (obj.scrollTop >= obj.firstChild.offsetWidth) {
// obj.scrollTop = 0;
//}
}
var _timer = setInterval("scroll(document.getElementById('scrollobj'))", 20);
function _stop() {
if (_timer != null) {
clearInterval(_timer);
}
}
function _start() {
_timer = setInterval("_scroll(document.getElementById('scrollobj'))", 20);
}
//-->
</script>
</body>
</html>
發(fā)表評論 共有條評論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 乌海市| 观塘区| 绵竹市| 崇仁县| 西丰县| 泰兴市| 鲜城| 广丰县| 东乡族自治县| 永泰县| 无锡市| 珠海市| 梁河县| 绥江县| 那坡县| 抚州市| 昌图县| 怀安县| 林芝县| 安丘市| 依安县| 特克斯县| 钦州市| 秀山| 若羌县| 阜新市| 漳浦县| 合川市| 义马市| 长岭县| 远安县| 晋江市| 荣成市| 丹阳市| 西盟| 虞城县| 盐边县| 宁陕县| 庄浪县| 乌苏市| 麟游县|