Home  >  Article  >  Web Front-end  >  div 包含 div问题_html/css_WEB-ITnose

div 包含 div问题_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-21 09:01:541004browse




为何2 设置margin-top之后1 页跟着往下20px?;不是应该2相对于1往下20px么?


回复讨论(解决方案)





如果这样子,3会相对于2往下20px;

这是CSS 外边距合并特性

http://www.w3school.com.cn/css/css_margin_collapsing.asp

每个元素都有其默认的外边距,1是由默认的外边距,你设置2的外边距为20px,两个外边距会进行合并取较大值。

内边聚试下呢?不知道行不

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn