-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfloat.html
More file actions
74 lines (70 loc) · 1.52 KB
/
float.html
File metadata and controls
74 lines (70 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style type="text/css">
.floatwrap {
border: 3px solid blue;
}
.floatwrap:after {
/*在float父元素的after中清理浮动*/
content: "\200B";
display: block;
height: 0;
clear: both;
}
.floatdiv {
/*浮动不影响其块级元素的布局,
* 但会影响相邻文本、行内元素、inline-block、float的排列
* */
float: left;
width: 20px;
margin: 1px;
border: 1px solid red;
text-align: center;
}
.rightfloatdiv{
float: right;
margin: 1px 1px 1px 10px;
text-align: center;
border: 1px solid red;
padding: 1 2px;
}
.inlineblockdiv{
border: 2px solid fuchsia;
display: inline-block;
width: 200px;
}
.border{
border: 2px solid yellow;
}
.end {
border: 1px solid green;
}
</style>
</head>
<body>
<div class="floatwrap">
<div class="floatdiv">1</div>
<div class="floatdiv">2</div>
<div class="floatdiv">3</div>
<div class="floatdiv">4</div>
<div class="floatdiv">5</div>
<div class="floatdiv">6</div>
<div class="rightfloatdiv">right888</div>
<!--前面元素的float不会影响这个div, 但会影响这个div中的文本和行内元素-->
<div class="border"><button>1111</button><button>2222</button></div>
<div class="inlineblockdiv">哈哈哈哈</div>
</div>
<div class="end">
end
</div>
<div class="end">
end2
</div>
<div class="end">
end3
</div>
</body>
</html>