好久没更新博客了,最近在赶做公司一个产品主页的制作。制作过程中又有了一些小收获,在这里记录下来
直接贴代码了,呵呵。也有注释的。其实就是添加了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>
<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>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架