<marquee direction=up behavior=scroll loop=3 scrollamount=1 scrolldelay=10 align=top bgcolor=#ffffff height=300 width=30% hspace=20 vspace=10 onmouseover=this.stop() onmouseout=this.start()>此处输入滚动内容 </marquee>
◎ direction表示滚动的方向,值可以是left,right,up,down,默认为left
◎ behavior表示滚动的方式,值可以是scroll(连续滚动)slide(滑动一次)alternate(往返滚动)
◎ loop表示循环的次数,值是正整数,默认为无限循环
◎ scrollamount表示运动速度,值是正整数,默认为6
◎ scrolldelay表示停顿时间,值是正整数,默认为0,单位似乎是毫秒
◎ align表示元素的垂直对齐方式,值可以是top,middle,bottom,默认为middle
◎ bgcolor表示运动区域的背景色,值是16进制的RGB颜色,默认为白色
◎ height、width表示运动区域的高度和宽度,值是正整数(单位是像素)或百分数,默认width=100% height为标签内元素的高度
◎ hspace、vspace表示元素到区域边界的水平距离和垂直距离,值是正整数,单位是像素。
◎ onmouseover=this.stop() onmouseout=this.start()表示当鼠标以上区域的时候滚动停止,当鼠标移开的时候又继续滚动。
通过此函数可以获取到鼠标滚动事件,然后做平移就好了/** Event handler for mouse wheel event.
*鼠标滚动事件
*/
var wheel = function(event) {
var delta = 0
if (!event) /* For IE. */
event = window.event
if (event.wheelDelta) { /* IE/Opera. */
delta = event.wheelDelta / 120
} else if (event.detail) {
/** Mozilla case. */
/** In Mozilla, sign of delta is different than in IE.
* Also, delta is multiple of 3.
*/
delta = -event.detail / 3
}
/** If delta is nonzero, handle it.
* Basically, delta is now positive if wheel was scrolled up,
* and negative, if wheel was scrolled down.
*/
if (delta)
handle(delta)
/** Prevent default actions caused by mouse wheel.
* That might be ugly, but we handle scrolls somehow
* anyway, so don't bother here..
*/
if (event.preventDefault)
event.preventDefault()
event.returnValue = false
}
/** Initialization code.
* If you use your own event management code, change it as required.
*/
if (window.addEventListener) {
/** DOMMouseScroll is for mozilla. */
window.addEventListener('DOMMouseScroll', wheel, false)
}
/** IE/Opera. */
window.onmousewheel = document.onmousewheel = wheel
/** This is high-level function.
* It must react to delta being more/less than zero.
*/
var handle = function(delta) {
var random_num = Math.floor((Math.random() * 100) + 50)
if (delta <0) {
// alert("鼠标滑轮向下滚动:" + delta + "次!")// 1
$("btn_next_pic").onclick(random_num)
return
} else {
// alert("鼠标滑轮向上滚动:" + delta + "次!")// -1
$("btn_last_pic").onclick(random_num)
return
}
}
方案1:设置2个DIV层,A1外层,A2内层,A2的宽度设置比A1宽20px左右(大概就是滚动条的宽度),A2设置为可见滚动条,A1设置为隐藏滚动条。可以滚动,但是看不到滚动条。前提是你必须在页面载入的时候将鼠标焦点对准到A2层上,如果焦点在A2层外,滚轮和下建无效。这个可以用js很容易做到。
方案2:直接把滚动条颜色设置和背景层一样。