DIV+CSS+javascript实现DIV对象显示在页面任何位置,并随滚动条移动

以下实现DIV对象随滚动条移动,始终显示在页面右下位置!

一:首先在head区域加入如下代码:

<SCRIPT LANGUAGE="JavaScript">
<!--
function scall()
{
ShowBottoms();
}
window.οnscrοll=scall;
window.οnresize=scall;
window.οnlοad=scall;
//-->
</SCRIPT>

二:在HEAD区域加入如下CSS代码:

<style type="text/css">
<!--

/* CSS Document */
#ShowBottom {
font:Arial, Helvetica, sans-serif;
font-size:14px;
width: 60px;
height:50px;
background:#FFFFFF;
border-right-color:#377CA6;
border-right-width:1px;
border-right-style:solid;
border-left-color:#377CA6;
border-left-width:1px;
border-left-style:solid;
border-top-color:#377CA6;
border-top-width:1px;
border-top-style:solid;
border-bottom-color:#377CA6;
border-bottom-width:1px;
border-bottom-style:solid;
position:absolute; bottom:0px; right:0px;
}
-->

</style>

三:在页面中的BODY任何地方加入如下代码

<div id=“ShowBottom“>初来乍到<br/>我想了解<br /><a HREF="www.51qqdm.cn" target="_blank">网站宗旨</a></div>

//下面这段代码必须跟在以上的DIV下面,否则就出错误!
<SCRIPT LANGUAGE="JavaScript">
<!--
function ShowBottoms()
{
document.getElementById("ShowBottom").style.top=(document.documentElement.scrollTop+document.documentElement.clientHeight-document.getElementById("ShowBottom").offsetHeight)+"px";
document.getElementById("ShowBottom").style.left=(document.documentElement.scrollLeft+document.documentElement.clientWidth-document.getElementById("ShowBottom").offsetWidth)+"px";
}
</SCRIPT>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值