5-3、float

#father{
    border:1px #000 solid
}
.layer01{
    border:1px #F00 dashed;
    display: inline-block;
    float: left;
}
.layer02{
    border:1px #F00 dashed;
    display: inline-block;
    float: left;
}
.layer03{
    border:1px #F00 dashed;
    display: inline-block;
    float: right;
}

5-4、父级边框塌陷问题

clear

/*
clear:left; 左侧不允许有浮动元素
clear:right; 右侧不允许有浮动元素
clear:both; 两侧不允许有浮动元素
*/

解决方案:

  1. 增加父级元素的高度

#father{
    border:1px #000 solid;
    height: 500px;
}

  1. 增加一个空的div标签,清除浮动

.clear{
    clear: both;
}

  1. overflow

在父级元素中增加一个 overflow:hidden
  1. 父类添加一个伪类:after

#father:after{
    content: '';
    display: block;
    clear: both;}

小结:

5-5、对比

链接:https://blog.csdn.net/clover_page/article/details/130100672

作者:姜伯約


上一条:【CSS3详解】六、定位
下一条:【CSS3详解】四、盒子模型

关闭本页

永乐高官方网站教育技术与网络中心版权所有

© by GDAFC Education Technology & Network Center, All Rights Reserved.

XML 地图