好久没更新博客了,最近在赶做公司一个产品主页的制作。制作过程中又有了一些小收获,在这里记录下来

      直接贴代码了,呵呵。也有注释的。其实就是添加了2行CSS,就可以让fixed元素在IE6下随滚动条而滚动却不闪动了。

     

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>底部广告条</title>
<style type="text/css">
*
{margin:0; padding:0;}
body
{background-color:#FFFFFF;}
.main
{width:980px; background-color:#FF0; margin:0 auto;}
.main p
{height:500px; width:100%;}
.fixed
{height:41px; width:100%; background-color:#03F;position:fixed; text-align:center; color:#FFFFFF;
    left
:0px;
    bottom
:0px;
    z-index
:999;/*为了让DIV永远在最前面,不被其他元素遮住*/
    _position
:absolute;/*这里开始的2句代码是为ie6不兼容position:fixed;而写的*/
    _top
:expression(eval(document.documentElement.scrollTop+documentElement.clientHeight-this.clientHeight));/*这里需要获取滚动高度+元素原本的高度*/
}
/*防止IE6下fixed元素闪动*/
*html
{
background-image
:url(about:blank);
background-attachment
:fixed;
}
</style>
</head>

<body>
<div class="main">
<p>aaaaaaaaaaaaaaaaaaaaaaaa</p><p>bbbbbbbbbbbbbbbbbbbbbbbbb</p><p>cccccccccccccccc</p>
</div>
<div class="fixed">我是滚动广告条</div>
</body>
</html>

相关文章:

  • 2022-03-03
  • 2021-11-23
  • 2022-01-12
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2021-08-06
猜你喜欢
  • 2021-09-05
  • 2022-12-23
  • 2022-12-23
  • 2021-05-31
  • 2022-12-23
  • 2021-07-28
  • 2022-01-17
相关资源
相似解决方案