Home  >  Article  >  Web Front-end  >  DIV implements automatic scrolling function and scroll bar color modification

DIV implements automatic scrolling function and scroll bar color modification

高洛峰
高洛峰Original
2017-03-16 16:43:473537browse

This article will introduce to you the implementation of DIV automatic scrollingfunction and scroll bar colormodification. The specific code is as follows:

<script type="text/javascript"> 
function startmarquee(lh, speed, delay) { 
var t; 
var oHeight = 300; /** p的高度 **/
var p = false; 
var o = document.getElementById("show"); 
var preTop = 0; 
o.scrollTop = 0; 
function start() { 
t = setInterval(scrolling, speed); 
o.scrollTop += 1; 
} 
function scrolling() { 
if (o.scrollTop % lh != 0
&& o.scrollTop % (o.scrollHeight - oHeight - 1) != 0) { 
preTop = o.scrollTop; 
o.scrollTop += 1; 
if (preTop >= o.scrollHeight || preTop == o.scrollTop) { 
o.scrollTop = 0; 
} 
} else { 
clearInterval(t); 
setTimeout(start, delay); 
} 
} 
setTimeout(start, delay); 
} 
window.onload = function () { 
/**startmarquee(一次滚动高度,速度,停留时间);**/
startmarquee(20, 40, 50); 
}  
</script>
 <p id="show" style="height: 600px; width: 100%; overflow-y: scroll;scrollbar-base-color:#ffffff;SCROLLBAR-HIGHLIGHT-COLOR:#ffffff;SCROLLBAR-ARROW-COLOR:#ffffff; overflow-x: none;"></p>

2. Scroll bar color

scrollbar-3d-light-color 设置或检索滚动条亮边框颜色  
crollbar-highlight-color 设置或检索滚动条3D界面的亮边(ThreedHighlight)颜色 
scrollbar-face-color 设置或检索滚动条3D表面(ThreedFace)的颜色  
scrollbar-arrow-color 设置或检索滚动条方向箭头的颜色 
scrollbar-shadow-color 设置或检索滚动条3D界面的暗边(ThreedShadow)颜色  
scrollbar-dark-shadow-color 设置或检索滚动条暗边框(ThreedDarkShadow)颜色  
scrollbar-base-color 设置或检索滚动条基准颜色。

The above is introduced to you by php Chinese websiteDIV The code for automatic scrolling function and scroll bar color modification , I hope it will be helpful to everyone.

Related articles:

CSS code to set p scroll bar color

How to distinguish different IE versions in the style sheet? How to make the scroll bar color compatible with IE8 and IE10?

Solution to the problem that the scroll bar color cannot be set in IE6

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn