-
Notifications
You must be signed in to change notification settings - Fork 28
/
1.html
49 lines (44 loc) · 1.13 KB
/
1.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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>item 宽度一定,所有元素都在一个容器</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.container {
width: 430px;
padding: 10px;
margin: 150px auto;
border: 2px solid rgb(240, 103, 103);
}
.item {
display: inline-block;
width: 100px; /* 宽度一定 */
margin-right: 30px;
margin-bottom: 20px;
padding: 5px 10px;
font-size: 20px;
border-radius: 5px / 5px;
background: rgb(103, 164, 243);
}
.item:nth-child(3n) {
margin-right: 0;
}
.item:nth-last-child(-n+3) {
margin-bottom: 0;
}
</style>
</head>
<body>
<div class='container'>
<div class='item'>最多放三个</div>
<div class='item'>最多放三个</div>
<div class='item'>最多放三个</div>
<div class='item'>最多放三个</div>
<div class='item'>最多放三个</div>
<div class='item'>最多放三个</div>
<div class='item'>最多放三个</div>
</div>
</body>
</html>