-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayout.html
159 lines (152 loc) · 3.51 KB
/
layout.html
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>双飞翼布局的几种方式</title>
<style media="screen">
html *{
margin:0;
padding:0;
}
.layout{
height:200px;
background:yellow;
margin-bottom:20px;
color:#fff;
font-size:22px;
line-height:200px;
text-align:center;
}
/*float布局*/
.float div{
height:200px;
}
.float div.left{
background:red;
float:left;
width:300px;
}
.float div.middle{
background:#000;
}
.float div.right{
background:green;
float:right;
width:300px;
}
/*position 布局*/
.layout{
position: relative;
}
.position div{
height:200px;
}
.position div.left{
position: absolute;
background:red;
width:300px;
left:0;
top:0;
}
.position div.middle{
position: absolute;
background:#000;
right:300px;
top:0;
left:300px;
}
.position div.right{
position: absolute;
background:green;
width:300px;
right:0;
top:0;
}
/*table-cell布局*/
.table-cell{
display:table;
width:100%;
}
.table-cell div{
height:200px;
display:table-cell;
}
.table-cell div.left{
width:300px;
background:red;
}
.table-cell div.middle{
background:#000;
}
.table-cell div.right{
width:300px;
background:green;
}
/*flex 布局*/
.flex{
display:flex;
}
.flex div{
height:200px;
}
.flex div.left{
background:red;
width:300px;
}
.flex div.right{
width:300px;
background:green;
}
.flex div.middle{
background:#000;
flex:1;
}
/*grid 网格布局*/
.grid{
display:grid;
grid-template-columns: 300px auto 300px;
}
.grid div.left{
background:red;
}
.grid div.middle{
background:#000;
}
.grid div.right{
background:green;
}
</style>
</head>
<body>
<!--float布局-->
<article class="float layout">
<div class="left">float布局-left</div>
<div class="right">float布局-right</div>
<div class="middle">float布局-middle</div>
</article>
<!--position布局-->
<article class="position layout">
<div class="left">position布局-left</div>
<div class="middle">position布局-middle</div>
<div class="right">position布局-right</div>
</article>
<!--table-cell布局-->
<article class="table-cell layout">
<div class="left">table-cell布局-left</div>
<div class="middle">table-cell布局-middle</div>
<div class="right">table-cell布局-right</div>
</article>
<!--flex布局-->
<article class="flex layout">
<div class="left">flex布局-left</div>
<div class="middle">flex布局-middle</div>
<div class="right">flex布局-right</div>
</article>
<!--grid网格布局-->
<article class="grid layout">
<div class="left">grid网格布局-left</div>
<div class="middle">grid网格布局-middle</div>
<div class="right">grid网格布局-right</div>
</article>
</body>
</html>