有关于margin的一点东西!

aries 发表于 2008-09-29 2480 次浏览 标签 : cssmarginfirefox

这里我要说一下css外容器margin的问题!

先看看下面的例子,

<!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=utf-8" />

<title>Demo-1</title>

<style type="text/css">

#wrapper{border:1px #999 solid; width:600px; margin-bottom:20px;}

.left{width:300px; float:left; height:100px; background:red;}

.right{width:300px; float:left; height:300px; background:#ccc;}

#footer{clear:both;width:600px;height:20px; background:#000;border:1px solid #ccc;}

</style>

</head>

<body>

<div id="wrapper">

      <div class="left"></div>

    <div class="right"></div>

</div>

<div id="footer"></div>

</body>

</html>

这是一个很简单的布局,注意我在#wrapper里面加上了margin-bottom:20px;

这个页面在IE6下是没有问题的!

但是firefox下却出了问题,margin-bottom根本就没起作用!

如何解决呢?如下,

#wrapper{border:1px #999 solid; width:600px; margin-bottom:20px;overflow:hidden;}

加上overflow:hidden;就可以了

3条评论

  1. 呵呵,有有有,大家都有头像,不要抢啊~

    aries 回复
  2. 呵呵 我试试有没有头像

    vin1980 回复
  3. overflow:hidden;是个好东西~

    vin1980 回复
如需评论,请填写表单。
换一个

记住我的信息