欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時間:2013年08月29日 18:02:57   作者:  
marquee無縫滾動想必大家都有見過,本文利用div+css+javascript也實現(xiàn)下類似的滾動且兼容firefox,喜歡的朋友可以參考下
div+css+javascript 實現(xiàn)無縫滾動,marquee無縫滾動,無縫滾動,兼容firefox

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

<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實現(xiàn)首尾相連循環(huán)滾動效果(兼容firefox):
復制代碼 代碼如下:

<!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 實現(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)++;
//當滾動條到達右邊頂端時
if (obj.scrollLeft == tmp) {
obj.innerHTML += obj.innerHTML;
}
//當滾動條滾動了初始內(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>

相關(guān)文章

最新評論