CSS清除浮动的方法
来源:互联网 发布:头条新闻软件下载 编辑:程序博客网 时间:2024/05/21 00:44
(1) clear 其中clear的值有none, both,left,right其中clear=both在网页中中的应用最大
(2) 额外标签法 直接上代码了
<style type="text/css">
.main{clear: both;} *****空标签的css属性
</style>
<body>
<div id="main">
<div id="left"></div>
<div id="right"></div>
<div class="main"></div> *******这里就是添加了额外的空标签
</div>
<div id="footer"> 底部</div>
</body>
(3) 父级元素使用overflow的方法: 通过设置给父级元素添加overflow:hidden;来实现,但是如果子元素使用了定位布局就很难实现
(4).类名{zoom:1} /*使用在 IE6和IE7 */
(5)邻接元素清除浮动的方法:
给它的相邻的元素设置clear:both;这样也可以达到其中那个清除浮动的结果
(6)使用伪类元素:after
直接上代码了:
css的代码:
#two{
width:95%;
margin: 0 auto;
clear:both;
content: " ";
display:block;
height:0;
}
#left{
width:45%;
height:400px;
float:left;
background-color: pink;
}
#right{
width:40%;
height:400px;
float:right;
background-color: yellow;
}
#three{
width:100%;
height:30px;
margin:0 auto;
background-color: green;
}
#four{
clear:both;
}
其中的html代码:
<div id="two">
<div id="left"></div>
<div id="right"></div>
<div id="four"></div>
<div id="three"></div>
</div>
- css 清除浮动的方法
- CSS清除浮动的方法
- CSS清除浮动的方法
- CSS 清除浮动的方法
- 清除css浮动的方法
- CSS清除浮动的方法
- css清除浮动的方法
- css清除浮动的方法
- CSS清除浮动的方法
- CSS清除浮动的方法
- css清除浮动的方法
- 为什么清除浮动?清除css浮动的三种方法
- CSS清除浮动方法
- CSS清除浮动方法
- CSS:清除浮动的最优方法
- 三种css清除浮动的方法
- CSS清除浮动的三个方法
- CSS清除浮动的简单方法
- 中国有和亲的传统
- 如何在自定义Listener(监听器)中使用Spring容器管理的bean
- SRM579 Div1Medium TravellingPurchasingMan
- C# File操作类
- CODEVS 1231 最优布线问题
- CSS清除浮动的方法
- JNI
- Vue学习笔记_03
- python函数参数之_可变参数
- 1014. 福尔摩斯的约会 (20)
- 查找--二分查找
- POJ 1753 Flip Game (DFS + 暴力枚举)
- 百度外卖面经( 2016-10-11更新)
- 编译器Sublime的导航栏sidebar的字体怎么调大