首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > CSS >

b div在a div中,在b中使用margin-top 为什么a也受到影响?该怎么处理

2012-02-06 
b div在a div中,在b中使用margin-top 为什么a也受到影响?HTML codehtmlheadtitleTestDiv/titlest

b div在a div中,在b中使用margin-top 为什么a也受到影响?

HTML code
<html><head>    <title>TestDiv</title>    <style type="text/css">        *{            padding:0;            margin:0;            }        #a{            width:960px;            height:700px;            background-color:red;            margin: 0 auto;        }        #b{            width:960px;            height:50px;            background-color:green;            margin-top: 10px;        }    </style></head><body>    <div id="a">        <div id="b">        </div>    </div></body></html>


[解决办法]
HTML code
<html><head>    <title>TestDiv</title>    <style type="text/css">        *{            padding:0;            margin:0;            }        #a{            width:960px;            height:700px;            background-color:red;            margin: 0 auto;        }        #b{            width:960px;            height:50px;            background-color:green;            margin-top: 10px;            float:left;            display:inline;        }    </style></head><body>    <div id="a">        <div id="b">        </div>    </div></body></html> 

热点排行