2.在IE里测试效果。
要完成此效果需要两个步骤第一步:把如下代码加入到<head>区域中
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function verScroll(dir, spd, loop) {
loop = true
direction = "up"
speed = 10
scrolltimer = null
if (document.layers) {
var page = eval(document.contentLayer)
}
else {
if (document.getElementById) {
var page= eval("document.getElementById( contentLayer ).style")
}
else {
if (document.all) {
var page = eval(document.all.contentLayer.style)
}
}
}
direction = dir
speed = parseInt(spd)
var y_pos = parseInt(page.top)
if (loop == true) {
if (direction == "dn") {
page.top = (y_pos - (speed))
} else {
if (direction == "up" &&y_pos <10) {
page.top = (y_pos + (speed))
} else {
if (direction == "top") {
page.top = 10
}
}
}
scrolltimer = setTimeout("verScroll(direction,speed)", 1)
}
}
function stopScroll() {
loop = false
clearTimeout(scrolltimer)
}
// End -->
</script>
第二步:把如下代码加入到<body>区域中
<div id="contentLayer" style="position:absolutewidth:300pxz-index:1left: 39pxtop: 51px">
aaaaaaaaaaaaaaaaaaaaaaa
bbbbbbbbbbbbbbbbbbbbbbb
ccccccccccccccccccccccccc
ddddddddddddddddddddddddd
eeeeeeeeeeeeeeeeeeeeeeeee
rrrrrrrrrrrrrrrrrrrrrrrr
ffffffffffffffffffffffg
ggggggggggggggggggggggggg
hhhhhhhhhhhhhhhhhhhhhhhhe
eeeeeeeeeeeeeeeeeeeeeee
</div>
<div id="scrollmenu" style="position:absolutewidth:236pxheight:30pxz-index:1left:328pxtop: 44px">
<table border=1><tr><td>
<table>
<tr>
<td align=left>Up</td>
<td></td>
<td align=right>Down</td>
</tr>
<tr>
<td colspan=3>
<a href="#" onMouseOver="verScroll( up , 25 , true )" onMouseOut="stopScroll()"><<<</a>
<a href="#" onMouseOver="verScroll( up , 5 , true )" onMouseOut="stopScroll()"><<</a>
<a href="#" onMouseOver="verScroll( up , 1 , true )" onMouseOut="stopScroll()"><</a>|
<a href="#" onMouseOver="verScroll( dn , 1 , true )" onMouseOut="stopScroll()">></a>
<a href="#" onMouseOver="verScroll( dn , 5 , true )" onMouseOut="stopScroll()">>></a>
<a href="#" onMouseOver="verScroll( dn , 25 , true )" onMouseOut="stopScroll()">>>></a>
</td>
</tr>
</table>
</td></tr></table>
</div>
我们在写html定义属性表的时候,经常会遇到这样的问题。
明明定义的宽和高都为100%,为什么body范围还是会超过屏幕范围呢,呈现结果如下:
我们通过显示margin边界可以看到其实,body默认是有margin值的:
通过在chrome中查看F12,也可以看到body的style中其实是有个默认的margin值的
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)