首页 > Web开发 > 详细

html-css:关于浮动的方式

时间:2017-04-08 22:49:15      阅读:236      评论:0      收藏:0      [点我收藏+]
1.在 The standard flow中内容的高度可以support父元素的高度
2.在 The standard flow中浮动的元素can not support父元素的高度

1.清除浮动的方式:
给前面一个父元素设置高度
notice:在企业开发中能不写就不写高度,这种方式用的很少

清除浮动的第二种方法: 添加clear属性
none 默认取值(左浮动找左浮动,右浮动找右浮动)/left (不要找前面的左浮动元素)/right(不要找前面的右浮动元素)/both(不要找前面的左、右浮动元素)
Notice:当我们给某个元素添加clear属性之后这个属性的margin属性就会失效。

<head>
<meta charset="UTF-8">
<title>clear attribute</title>
<style>
*{
margin: 0;
padding: 0;
}
.box1{

background-color: red;
}
.box2{
background-color: green;
clear: both;
}
.box1 p{
width: 100px;
background-color: blue;
}
.box2 p{
width: 100px;
background-color: yellow;
}
p{
float:left ;
}
</style>
</head>
<div class="box1">
<p>秦怡大傻瓜1</p>
<p>秦怡大傻瓜1</p>
<p>秦怡大傻瓜1</p>
</div>
<div class="box2">
<p>秦怡大傻瓜2</p>
<p>秦怡大傻瓜2</p>
<p>秦怡大傻瓜2</p>
</div>

技术分享


html-css:关于浮动的方式

原文:http://www.cnblogs.com/zmyhk/p/6683097.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!