关于position在各浏览中的表现问题
来源:互联网 发布:淘宝卖家早点收到货款 编辑:程序博客网 时间:2024/06/11 14:31
关于css中的position在各大浏览器(IE,FireFox,Opera)中表现问题:
第一种情况:
<!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=gb2312" />
<title>无标题文档</title>
<style type="text/css">...
#div-1
{...}{
position:relative;
top:0px;
left:150px;
background:#CC9933;
border:1px solid #66FF66;
width:400px;
height:300px;
}
#div-1a
{...}{
position:absolute;
top:0;
left:0;
width:100px;
height:600px;
background:#9999FF;
}
.autoCenter
{...}{
margin:0 auto;
border:1px solid #6595d6;
}
.clearBoth
{...}{
height:1px;
clear:both;
}
.divFather
{...}{
height:400px; overflow:scroll;border:2px solid #ccc;
width:600px;
}
.divA
{...}{
position:relative;
}
</style>
</head>
<body scroll="no" >
<br />
<br />
<div class="divFather">
<div id="div-1">
<p>d </p>
<p>dfd</p>
</div>
<div id="div-1a"> df</div>
<div class="clearBoth"></div>
<div class="autoCenter">
<p>d</p>
<p> </p>
</div>
<div class="autoCenter">
<p>d</p>
<p> </p>
</div>
</div>
<!--
<div id="div-1" class="divFather">
<div id="div-1a">
this is div-1a element.
</div>
this is div-1 element.
</div>
-->
</body>
</html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">...
#div-1
{...}{
position:relative;
top:0px;
left:150px;
background:#CC9933;
border:1px solid #66FF66;
width:400px;
height:300px;
}
#div-1a
{...}{
position:absolute;
top:0;
left:0;
width:100px;
height:600px;
background:#9999FF;
}
.autoCenter
{...}{
margin:0 auto;
border:1px solid #6595d6;
}
.clearBoth
{...}{
height:1px;
clear:both;
}
.divFather
{...}{
height:400px; overflow:scroll;border:2px solid #ccc;
width:600px;
}
.divA
{...}{
position:relative;
}
</style>
</head>
<body scroll="no" >
<br />
<br />
<div class="divFather">
<div id="div-1">
<p>d </p>
<p>dfd</p>
</div>
<div id="div-1a"> df</div>
<div class="clearBoth"></div>
<div class="autoCenter">
<p>d</p>
<p> </p>
</div>
<div class="autoCenter">
<p>d</p>
<p> </p>
</div>
</div>
<!--
<div id="div-1" class="divFather">
<div id="div-1a">
this is div-1a element.
</div>
this is div-1 element.
</div>
-->
</body>
</html>
(1)、IE中解释良好,ID为div-1的元素如期在其容器类名为divFather中,相对固定在某一个位置,通过这个功能做固定表头效果非常的方便。
(2)、而ID为div-1的元素在Opera和和FireFox中它会随着滚动条的而滚动,也就是说起不到relative 的作用。
第二种情况:
#div-1
{
position:relative;
top:0px;
left:150px;
background:#CC9933;
border:1px solid #66FF66;
width:400px;
height:500px;
}
{
position:relative;
top:0px;
left:150px;
background:#CC9933;
border:1px solid #66FF66;
width:400px;
height:500px;
}
我们将修改#div-1中的heigth属性,让它的高度高于其容器.divFather时,发现这时IE的解析与我想象中的不同
(1)、在IE中ID为div-1的元素突破了其容器而显示在外部,也就是说position:relative;中起不到相对于其容器的位置,而是相对于浏览器也就是窗口,在IE中设置position为relative时它与任何的元素是没有关联的,它的位置在哪也也不会影响到任何元素的布局。
(2)、Opera和FireFox中解析则不同,尽管position设为relative但它也只显示到其容器中。
来到这里我就想如果像第一种情况时浏览器解析得像IE,而在第二种情况解析得像Opera或FireFox那不是更好,更是我们想要看到的?
不如各高手有何解决的方法呢??
- 关于position在各浏览中的表现问题
- 列表在各浏览器中的表现差异
- unix网络编程I卷之关于wait在不同系统中的表现扩展出来的问题
- 关于css中的position
- 关于position中的relative
- 栈变量被覆盖的问题在不同编译器中的表现,蛋疼的VC++
- 沙盒效应在百度中的表现
- DIV+CSS在不同浏览器中的表现
- scrollHeight在chrome中的异常表现
- JQuery在XSS攻击中的表现
- thinkphp表现层中的路径问题
- 微信小程序中的position问题
- 关于利用position定位在页面正中心的问题(还有一个z-index的知识点)
- 报名 | XGBoost模型原理及其在各大竞赛中的优异表现
- 关于jQuery中的offset()和position()
- 关于CSS中的float和position
- 关于CSS中的float和position
- 关于CSS中的float和position
- 燕南园的猫
- 从Oracle WMS角度看仓库拣选面的存储策略
- 浅谈Java中final,finalized,finally
- 关于JDBC的学习总结,新手写的第一篇学习帖子
- SaaS浪潮即将引爆 CIO如何理智应对?
- 关于position在各浏览中的表现问题
- Web中使用多线程来增强用户体验
- 长文章分页程序(根据设定标记)
- Java技术美好未来
- dns
- 利用.net2.0中的GZip或Deflate压缩文件
- Request.QueryString 汉字编码问题
- 我的收藏夹之网络链接
- 一个图标搜索网站