固定的页面布局在IE6
-
09-06-2019 - |
题
标题、脚注和侧边有固定的位置。在该中心内容的领域与两个滚动条。没有外滚动条浏览器。我有一个布局,在IE7和FF.我需要添加IE6支持。我如何可以使这项工作?
这里是一个近似的我的前CSS。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title>Layout</title>
<style>
* {
margin: 0px;
padding: 0px;
border: 0px;
}
.sample-border {
border: 1px solid black;
}
#header {
position: absolute;
top: 0px;
left: 0px;
right: 0px;
height: 60px;
}
#left-sidebar {
position: absolute;
top: 65px;
left: 0px;
width: 220px;
bottom: 110px;
}
#right-sidebar {
position: absolute;
top: 65px;
right: 0px;
width: 200px;
bottom: 110px;
}
#footer {
position: absolute;
bottom: 0px;
left: 0px;
right: 0px;
height: 105px;
}
@media screen {
#content {
position: absolute;
top: 65px;
left: 225px;
bottom: 110px;
right: 205px;
overflow: auto;
}
body #left-sidebar,
body #right-sidebar,
body #header,
body #footer,
body #content {
position: fixed;
}
}
</style>
</head>
<body>
<div id="header" class="sample-border"></div>
<div id="left-sidebar" class="sample-border"></div>
<div id="right-sidebar" class="sample-border"></div>
<div id="content" class="sample-border"><img src="/broken.gif" style="display: block; width: 3000px; height: 3000px;" /></div>
<div id="footer" class="sample-border"></div>
</body>
</html>
解决方案
可能会被矫枉过正的项目,但是 院长爱德华兹'IE7javascript增加了支持固定的位于IE6.
其他提示
添加以下代码 <head>
<!--[if lte IE 6]>
<style type="text/css">
html, body {
height: 100%;
overflow: auto;
}
.ie6fixed {
position: absolute;
}
</style>
<![endif]-->
添加 ie6fixed
CSS类到任何你想要的 position: fixed;
尝试IE7.js.应该可以解决你的问题没有作出任何修改。
链接: IE7.js
这些问题的答案是有帮助的,他们有没有让我加入的有限形式的固定定位IE6,但是没有这些修复的错误,打破了我的布局在IE6如果我同时指定一个顶部和底部css酒店对我的侧栏(其行为我需要).
由于顶部和底部不能被指定,我使用的顶级和高度。高度的财产被证明是非常必要的。我用javascript重新计算的高度时,页面上的负荷,并对任何调整。
下面是代码,我加入到我的测试案例得到它的工作。这可能是更清洁的用!
<!--[if lt IE 7]>
<style>
body>div.ie6-autoheight {
height: 455px;
}
body>div.ie6-autowidth {
right: ;
width: 530px;
}
</style>
<script src="http://ie7-js.googlecode.com/svn/version/2.0(beta3)/IE7.js" type="text/javascript"></script>
<script type="text/javascript">
function fixLayout() {
if (document.documentElement.offsetWidth) {
var w = document.documentElement.offsetWidth - 450;
var h = document.documentElement.offsetHeight - 175;
var l = document.getElementById('left-sidebar');
var r = document.getElementById('right-sidebar');
var c = document.getElementById('content');
c.style.width = w;
c.style.height = h;
l.style.height = h;
r.style.height = h;
}
}
window.onresize = fixLayout;
fixLayout();
</script>
<![endif]-->
检查了纯css黑客下面...一些需要迫使它进入的怪癖模式(我认为这是最强大的),但所有的工作真的很好:
http://ryanfait.com/resources/fixed-positioning-in-internet-explorer/ http://tagsoup.com/cookbook/css/fixed/
我用这个向伟大的效果,希望它能帮助!
不隶属于 StackOverflow