平移吗?用css的position和top、left更改。
<div style="position:fixedtop:10px/*这里是这个div到浏览器边框顶部距离*/left:20px/*这个是div到浏览器左边框的距离*/"></div><!--表格-->当然可以呀,这种布局方式叫做绝对定位
box_absolute是图中的框2
#box_absolute {position: absolute
left: 30px
top: 20px
}
绝对定位的元素的位置相对于最近的已定位祖先元素,如果元素没有已定位的祖先元素,那么它的位置相对于最初的包含块。
这里的偏移量,即所谓的坐标x(left)和y(top),css中本身是没有x和y这2个属性的
通过此函数可以获取到鼠标滚动事件,然后做平移就好了/** 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
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)