div#footer{background-color:#333; color:white; clear:both;height:50px}#footer没加clear:both;为什么height:50px}根本就显示不出来

来源:学生作业帮助网 编辑:作业帮 时间:2024/07/27 15:31:58
div#footer{background-color:#333; color:white; clear:both;height:50px}#footer没加clear:both;为什么height:50px}根本就显示不出来
xSmO@*U&7@.(d6>$FS7L !>]XҖ¾ ]DzN _4{l..%ֲ 뢨Trӆ,n>9Q.D"LVIC.)Q2FF,K3 E#4-Tlİ~O:-[%8qHOKo'zSKR"j3S hR-PGh^t}BغHM3LTtx^ AO Z* 7ƪN~PBN]4J:V .".O@-(XAQv;M)2 fs9lyyALt~Ռx!0ح'y,'c@5ZؾL+c Iټ9CE91PT̷/eigt?4 㘡 M]M)OLo38

div#footer{background-color:#333; color:white; clear:both;height:50px}#footer没加clear:both;为什么height:50px}根本就显示不出来
div#footer{background-color:#333; color:white; clear:both;height:50px}
#footer没加clear:both;为什么height:50px}根本就显示不出来

div#footer{background-color:#333; color:white; clear:both;height:50px}#footer没加clear:both;为什么height:50px}根本就显示不出来
① 题主要首先明白,clear:both 的用途,给你个链接看看~
简单来说,clear:both 的用处就是,清除上方元素“浮动导致高度坍塌”(容器高度为0).


② 清楚了 clear:both 是用来清除浮动之后:
  如果 #footer 没加 clear:both;,就会使 #footer 上方的元素没有清除浮动.
  也就是说,加入  #footer 上方的元素是设置了 float,或者  #footer 上方的元素的子元素设置了 float,导致高度坍塌,#footer 就会被上方的元素 遮盖了,导致 #footer 显示不出来