-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathdemo.html
89 lines (78 loc) · 2.05 KB
/
demo.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
<!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>
span,
div,
img,
a {
outline: 1px dotted;
}
.author,
.info {
/* 行内块垂直对齐 */
vertical-align: middle;
/* 让这2个元素在一行内显示 */
display: inline-block;
}
.name,
.email {
/* 2行 */
display: block;
}
/* ***************************************** */
/* 垂直居中 */
.meta2 {
height: 20em;
border: 1px solid red;
}
.meta2:before {
content: '';
display: inline-block;
/* 设置对其几点 */
vertical-align: middle;
height: 100%;
width: 10px;
background: yellow;
}
.author2,
.info2 {
/* 行内块垂直对齐 */
vertical-align: middle;
/* 让这2个元素在一行内显示 */
display: inline-block;
}
.name2,
.email2 {
/* 2行 */
display: block;
}
</style>
</head>
<body>
<h1><a id="demo1">行内块布局垂直对齐</a></h1>
<p class="meta">
<img src="avatar.png" alt="" class="author">
<span class="info">
<span class="name">
晓风轻
</span>
<a href="mailto:[email protected]" class="email">[email protected]</a>
</span>
</p>
<h1><a id="demo2">容器内垂直对齐</a></h1>
<p class="meta2">
<img src="avatar.png" alt="" class="author2">
<span class="info2">
<span class="name2">
晓风轻
</span>
<a href="mailto:[email protected]" class="email2">[email protected]</a>
</span>
</p>
</body>
</html>