网页前端设计

http://www.86y.org

搜索文章

网页缩小放大后错位的解决方法

用声音读出全文关注我吧
 2011/8/2 17:14:12 阅读次数:20482

今天同事人说网页缩小放大错位了,我就看了下真的错位了!纳闷怎么会这样,我仔细的看了看(心想谁会把网页缩小放大了看),最后还是没办法说服上级,只能找方法解决了。经过仔细查看找到了问题所在。

有多种原因。

1、因为宽度原因。

2、浮动原因(我就是这个问题)

我是一个大DIV(固定宽度的)里面有两个小DIV(也是固定宽度的)一个左边一个右边。我也不知道为什么会错位,我就试着改样式。

左边宽度不变,右边我把宽度去掉了,并且去掉了浮动。加个margin-left:左边的宽度。然后就正常了。
代码如下:

<!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>
.clearfix:after{ content:"."; display:block;height:0;clear:both; visibility:hidden;} 
*html .clearfix{height:1%;}
*+html .clearfix{height:1%;}
.clearfix{display:inline-block;}
.clearfix {display:block;} 

.com{width:800px;padding:10px;border:1px solid #333;background:#eee;}
.left,.right{height:100px;}
.left{width:200px;background:#f60;float:left;display:inline;}
.right{margin-left:200px;background:#000;}
.r_c{width:100%;margin-right:10px;}
</style>
</head>
<body>
<div class="com clearfix">
	<div class="left">adfaaaaaaaaaaaaaaa</div>
	<div class="right"><div class="r_c">adfaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa</div></div>
</div>
</body>
</html>

这样就解决了网页缩小放大的问题


大家有什么问题或技术上的想法可以在此与大家分享,也可以加入前端爱好者QQ群(141999928)一起学习进步:【幸凡前端技术交流群】
0

如果您觉得本文的内容对您的学习有所帮助,捐赠与共勉,支付宝(左)或微信(右)

阅读全文内容关闭