`
shirlly
  • 浏览: 1624805 次
  • 性别: Icon_minigender_2
  • 来自: 福州
社区版块
存档分类
最新评论

兼容比较好的一个浮动层代码.css xhtml

    博客分类:
  • CSS
阅读更多
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<a href="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" target="_blank" rel="external">http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd</a>">
<html xmlns="<a href="http://www.w3.org/1999/xhtml" target="_blank" rel="external">http://www.w3.org/1999/xhtml</a>">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
</head>

<body>
<!--***********开始*************-->
<script type="text/javascript">
//<![CDATA[
var tips; var theTop = 200/*这是默认高度,越大越往下*/; var old = theTop;
function initFloatTips() {
  tips = document.getElementById('floatTips');
  moveTips();
};
function moveTips() {
  var tt=50;
  if (window.innerHeight) {
    pos = window.pageYOffset
  }
  else if (document.documentElement && document.documentElement.scrollTop) {
    pos = document.documentElement.scrollTop
  }
  else if (document.body) {
    pos = document.body.scrollTop;
  }
  pos=pos-tips.offsetTop+theTop;
  pos=tips.offsetTop+pos/10;
  if (pos < theTop) pos = theTop;
  if (pos != old) {
    tips.style.top = pos+"px";
    tt=10;
  }
  old = pos;
  setTimeout(moveTips,tt);
}
//!]]>
</script>
<style type="text/css">
div#floatTips{
 position:absolute;
 border:solid 1px #777;
 padding:3px;
 top:250px;
 left:500px;
 width:300px;
 background:#cccccc;
 color:white;
}
</style>
</head>
<body onload="initFloatTips()">
<div id="floatTips">
 浮动层
</div>
<!--**********结束***************-->
<table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#F7F7F7">
  <tr>
    <td height="2101"> </td>
  </tr>
</table>
</body>
</html>




转自:http://www.lioil.net/LBS/article.asp?id=418
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics