-
Notifications
You must be signed in to change notification settings - Fork 0
/
flex.html
66 lines (54 loc) · 1.56 KB
/
flex.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
<!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>
*{
margin: 0;
padding: 0;
box-sizing: border-box
}
.body{
max-width: 1200px;
margin: 0 auto;
border: 1px solid red
}
/*
原来是这样,以前不懂为什么在bootstrap里面,.row这个类需要设置左右负margin,而且这个负margin的值恰好又是row里面的div的padding的值
可能是bootstrap为了兼容多列的情况吧,以前的时候,对于多列,中间有确定的间隔,而一行的开头和结尾的元素却只有一边有间隔这样的需求不知道怎么做,
现在才知道可以利用row容器设置左右负margin抵消开头和结尾的那一侧的间距
*/
ul{
display: flex;
flex-wrap: wrap;
list-style: none;
margin-left: -10px;
margin-right: -10px
}
ul li{
width: 33.333%;
padding: 0 10px;
margin-bottom: 10px;
/* border: 1px solid black; */
height: 200px;
background-color: blueviolet;
background-clip: content-box
}
</style>
</head>
<body>
<div class="body">
<h2>对齐啦啦</h2>
<ul>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
</div>
</body>
</html>