-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathone.html
More file actions
161 lines (139 loc) · 2.35 KB
/
one.html
File metadata and controls
161 lines (139 loc) · 2.35 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
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
160
161
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>一列垂直居中-9种思路</title>
<style>
*{
margin:0;
padding:0;
}
.box{
width: 700px;
height: 300px;
margin: 0 auto 50px;
border:2px solid green;
}
p.tit{
text-align: center;
font-size: 30px;
font-weight: bold;
margin-bottom: 10px;
}
.box p{
background: yellow;
}
.box1{
line-height: 300px;
}
.box2{
position: relative;
}
.box2 p{
position: absolute;
top: 50%;
height: 100px;
margin-top: -50px;
}
.box3{
position: relative;
}
.box3 p{
position: absolute;
top:50%;
transform: translateY(50%);
}
.box4{
display: table-cell;
vertical-align: middle;
}
.box5{
position: relative;
}
.box5 p{
position: fixed;
top:0;
bottom:0;
left:0;
right:0;
margin:auto;
width: 100px;
height: 100px;
}
.box6{
}
.box6:before{
content: "";
height: 100%;
vertical-align: middle;
visibility: hidden;
display: inline-block;
}
.box6 p{
display: inline-block;
}
.box7{
}
.box7 span{
height: 100%;
width: 1px;
vertical-align: middle;
display: inline-block;
}
.box7 p{
display: inline-block;
}
.box8{
display: -webkit-box;
-webkit-box-align:center;
}
.box9{
position: relative;
}
.box9 p{
position: absolute;
height: 100px;
top: -webkit-calc(50% - 100px / 2);
}
</style>
</head>
<body>
<p class="tit">line-height</p>
<div class="box box1">喵喵哒~</div>
<p class="tit">absolute+margin</p>
<div class="box box2">
<p>
汪汪汪~
</p>
</div>
<p class="tit">absolute + tansform(定位元素基准为父元素,transform偏移参考点为自身)</p>
<div class="box box3">
<p>biabiabia~</p>
</div>
<p class="tit">table-cell</p>
<div class="box box4">
<p>强强强强</p>
</div>
<p class="tit">fixed margin</p>
<div class="box box5">
<p>劳资来啦!</p>
</div>
<p class="tit">before+margin</p>
<div class="box box6">
<p>bibibibibibibo~</p>
</div>
<p class="tit">vertical-align</p>
<div class="box box7">
<span></span>
<p>哈哈哈哈哈哈</p>
</div>
<p class="tit">-webkit-box</p>
<div class="box box8">
<p>balala;a;a;;a;a</p>
</div>
<p class="tit">absolute + calc</p>
<div class="box box9">
<p>biubiubiubiubiu---></p>
</div>
</body>
</html>