让IE6下支持固定定位
让IE下支持固定定位
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/xhtml"> 3 <head> 4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 5 <title>无标题文档</title> 6 <style> 7 body { 8 _background-image: url(null); /*空背景*/ 9 /*_background-image: url(about:blank);*/ 10 _background-attachment: fixed; /* 固定背景 */ 11 } 12 13 #fixed { 14 position: fixed; 15 top: 50%; /* 非IE下的定位 */ 16 _position: absolute; /*IE6 用absolute模拟fixed*/ 17 _top: expression(document.documentElement.scrollTop + Math.round ( 18 document.documentElement.offsetHeight/ 2)+ "px"); /*IE6 动态top值*/ 19 right: 0; 20 width: 30px; 21 height: 100px; 22 margin-top: -50px; 23 background: #F30; 24 } 25 </style> 26 </head> 27 <body style="height: 3000px;"> 28 <div id="fixed"></div> 29 </body> 30 </html>
1 <style> 2 .box{height:2000px;} 3 .div{width:100px;height:100px;background:red; position:fixed;left:100px;top:100px; _position:absolute;_top:expression(eval(document.documentElement.scrollTop+100)); 4 } 5 </style> 6 </head> 7 <body> 8 <div class="box"> 9 <div class="div"></div> 10 </div>
分类:
HTML&CSS
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 周边上新:园子的第一款马克杯温暖上架
· Open-Sora 2.0 重磅开源!
· .NET周刊【3月第1期 2025-03-02】
· 分享 3 个 .NET 开源的文件压缩处理库,助力快速实现文件压缩解压功能!
· [AI/GPT/综述] AI Agent的设计模式综述