- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
css中一些兼容性问题和的技巧
设置float:left时父元素height不能自适应的兼容问题
代码:
style type=text/css
#box{ width:800px; border:5px #333333 solid;}
#left{ width:360px; background:#FF0000;height:250px; float:left;}
#right{float:left; width:360px; background:#0000FF;height:250px;}
/style
body
div id=box
div id=left/div
div id=right/div
/div
/body
(1)在IE6和IE7中显示如下:
(2)在IE8和IE9 中显示如下:
(3)在firefox和opera中显示如下:
解决办法:在父元素中添加 overflow:hidden
代码如下:
style type=text/css
#box{ width:800px; border:5px #333333 solid;overflow;hidden}
#left{ width:360px; background:#FF0000;height:250px; float:left;}
#right{float:left; width:360px; background:#0000FF;height:250px;}
/style
修改后:IE、firefox、opera 中显示如下:
当同时设置float:left和margin时IE6会产生双倍margin值
代码如下:
style type=text/css
#box{ width:800px; border:5px #333333 solid; overflow:hidden}
#left{ width:360px; background:#FF0000;height:250px; float:left; margin:0px 20px;}
#right{float:left; width:360px; background:#0000FF;height:250px; margin:0px 20px;}
/style
/head
body
div id=box
div id=left/div
div id=right/div
/div
/body
在IE6中显示如下:
在IE7、IE8、IE9、firefox、opera中显示如图:
解决方法:添加display:inline
修改后:IE、firefox、opera 中显示如下:
margin不能撑开height
代码如下:
style type=text/css
#box {background-color:#eee; width:300px; }
#inbox{margin-top: 20px;margin-bottom: 20px; text-align:center }
/style
body
div id=box
div id=inbox对象中的内容/div
/div
/body
IE6和IE7能够撑开,如图:
IE8 、IE9、firefox、和opera不能撑开。如图:
解决办法一:在#inbox对象上下各加2个空的div对象CSS代码:.1{height:0px;overflow:hidden;}
代码如下:
style type=text/css
#box {background-color:#eee; width:300px; }
#inbox{margin-top: 20px;margin-bottom: 20px; text-align:center;}
.hidden{height:0px;overflow:hidden}
/style
body
div id=box
div class=hidden/div
div id=inboxp对象中的内容/div
div class=hidden/div
/div
/body
修改后: IE、firefox、opera 显示如图:
解决方法二:为#box加上border属性
代码如下:
style type=text/css
#box {background-color:#eee; width:300px; border:1px #666666 solid }
#inbox{margin-top: 20px;margin-bottom: 20px; text-align:center;}
/style
body
文档评论(0)