Skip to content

Commit ca44047

Browse files
committed
css实现元素水平垂直居中
1 parent a229b55 commit ca44047

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>元素水平垂直居中</title>
6+
<style>
7+
body,
8+
html{
9+
height: 100%;
10+
}
11+
.container{
12+
border: 1px solid #ddd;
13+
height: 100%;
14+
15+
display: flex;
16+
flex-direction: column;
17+
align-items: center;
18+
justify-content: center;
19+
}
20+
.container .img{
21+
width: 100px;
22+
height: 100px;
23+
background-color: #ddd;
24+
border-radius: 100%;
25+
overflow: hidden;
26+
}
27+
</style>
28+
</head>
29+
<body>
30+
<div class="container">
31+
<div class="img">...</div>
32+
<div class="title">...</div>
33+
<div class="info">...</div>
34+
</div>
35+
</body>
36+
</html>

0 commit comments

Comments
 (0)