-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVertical centering.html
More file actions
139 lines (120 loc) · 3 KB
/
Vertical centering.html
File metadata and controls
139 lines (120 loc) · 3 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<style>
html,
body {
margin: 0;
padding: 0;
height: 100%;
background-color: #000;
}
div,
span,
p {
-moz-box-sizing: border-box;
/*Firefox3.5+*/
-webkit-box-sizing: border-box;
/*Safari3.2+*/
-o-box-sizing: border-box;
/*Opera9.6*/
-ms-box-sizing: border-box;
/*IE8*/
box-sizing: border-box;
}
.line .block {
width: 300px;
height: 300px;
position: relative;
background-color: transparent;
margin: .5% 1%;
float: left;
border: 1px solid #fff;
}
.flex {
display: flex;
justify-content: center;
align-items: Center;
}
.minus_margin {
position: absolute;
width: 100px !important;
height: 100px !important;
top: 50%;
left: 50%;
margin-left: -50px;
/*需要固定高度宽度*/
margin-top: -50px;
text-align: center;
}
.zero {
position: absolute;
margin: auto;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.translate {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}
.content {
height: 50%;
width: 50%;
background-color: #fff;
}
.inline_block {
text-align: center;
font-size: 0;
}
.inline_block:after {
content: '';
width: 0;
height: 100%;
display: inline-block;
vertical-align: middle;
}
.vertical_middle {
vertical-align: middle;
display: inline-block;
}
.clearfix:after {
content: " ";
display: block;
clear: both;
height: 0;
}
.clearfix {
zoom: 1;
}
</style>
</head>
<body>
<div class="line clearfix">
<div class="block flex">
<div class="content"></div>
</div>
<div class="block ">
<div class="content minus_margin"></div>
</div>
<div class="block">
<div class="content zero"></div>
</div>
<div class="block">
<div class="content translate"></div>
</div>
</div>
<div class="line clearfix">
<div class="block inline_block">
<div class="content vertical_middle"></div>
</div>
</div>
</body>
</html>