子div與父div可以設(shè)置邊界,那為什么給子div設(shè)置上邊距后,子div與父div沒有作用啊,反倒父div有了上邊距啊
??? <div id="fu">
??????? <div id="zi">子div</div>
??? </div>
#fu{? /*父div設(shè)置寬 高300px 背景紅色 */
??? width:300px; ?
??? height:300px;
?? ?background:red;
}
#zi{margin-top:30px; /*子div設(shè)置上邊距30px 背景綠色 */
??? background:green;
}
2016-05-14
為fuID選擇器加上border,看的會(huì)清楚一些
#fu{
width:300px;
height:300px:
background:red:
border:20px solid blue;
}
2016-05-12
#fu{ ?/*父div設(shè)置寬 高300px 背景紅色 */
? ? width:300px; ?
? ? height:300px;
? ? background:red;?
? ? position:relative;
}
#zi{margin-top:30px; /*子div設(shè)置上邊距30px 背景綠色 */
? ? background:green;
? ? position:absolute;
}
2016-05-12
加一句就好
#zi{margin-top:30px; /*子div設(shè)置上邊距30px 背景綠色 */
? ? background:green;
? ? position:absolute;
}