【ie7】下关于【absolute 和float】 导致高度塌陷的问题,求解_html/css_WEB-ITnose

php中文网
发布: 2016-06-21 09:46:03
原创
1645人浏览过

本帖最后由 wangyinshu 于 2013-09-12 16:58:05 编辑

ie7 absolute 高度塌陷

ie8以及以上版本中此段代码是我要达到的效果,但是ie7不知何故导致了left,right类的高度塌陷。求高手解答。怎样兼容ie7

代码如下:
<!DOCTYPE html><html><head>	<title></title><style type="text/css">.content{	position: absolute;	top: 20px;	bottom: 20px;	background-color: #eee;	left: 0;	right: 0;}.left{	height: 100%;	width: 40%;	float: left;	position: relative;	background-color: #888;}.right{	position: relative;	height: 100%;	width: 60%;	float: left;	background-color: #666;}.img{	width: 100px;	background-color: red;	height: 200px;	float: right;	position: relative;	top: 50%;	margin-top: -100px;}.detail{	width: 300px;	height: 300px;	float: left;	position: relative;	top: 50%;	margin-top: -150px;	background-color: green;}.clearfix{	*zoom: 1;}.clearfix:after,.content-style:after{	clear: both;	content: "20";	visibility: hidden;	height: 0;	display: block;}</style></head><body>	<div class="content clearfix">		<div class="left clearfix">			<div class="img"></div>		</div>		<div class="right clearfix">			<div class="detail"></div>		</div>			</div></body></html>
登录后复制
登录后复制

回复讨论(解决方案)

忘记粘贴代码了   代码在此:

<!DOCTYPE html><html><head>	<title></title><style type="text/css">.content{	position: absolute;	top: 20px;	bottom: 20px;	background-color: #eee;	left: 0;	right: 0;}.left{	height: 100%;	width: 40%;	float: left;	position: relative;	background-color: #888;}.right{	position: relative;	height: 100%;	width: 60%;	float: left;	background-color: #666;}.img{	width: 100px;	background-color: red;	height: 200px;	float: right;	position: relative;	top: 50%;	margin-top: -100px;}.detail{	width: 300px;	height: 300px;	float: left;	position: relative;	top: 50%;	margin-top: -150px;	background-color: green;}.clearfix{	*zoom: 1;}.clearfix:after,.content-style:after{	clear: both;	content: "20";	visibility: hidden;	height: 0;	display: block;}</style></head><body>	<div class="content clearfix">		<div class="left clearfix">			<div class="img"></div>		</div>		<div class="right clearfix">			<div class="detail"></div>		</div>			</div></body></html>
登录后复制
登录后复制

ie8以及以上版本中此段代码是我要达到的效果,但是ie7不知何故导致了left,right类的高度塌陷。求高手解答。怎样兼容ie7

你这height:100%在ie7下貌似没用,要不用js吧

浏览器的问题,这没办法,找个代替方案吧

HTML速学教程(入门课程)
HTML速学教程(入门课程)

HTML怎么学习?HTML怎么入门?HTML在哪学?HTML怎么学才快?不用担心,这里为大家提供了HTML速学教程(入门课程),有需要的小伙伴保存下载就能学习啦!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号