-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflexbox.html
82 lines (75 loc) · 2.38 KB
/
flexbox.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Flex Essentials</title>
<style>
.container {
display: flex;
/* display the flex container inline */
/* display: inline-flex; */
background-color: #ccc;
border: 1px solid black;
flex-direction: row;
justify-content: flex-start;
align-items: center;
flex-wrap: wrap;
row-gap: 2rem;
/* column-gap: 20px; */
/* align the flex items within the container when container is large */
/* align-content: space-between; */
}
.item {
border: 1px solid #333;
background-color: #777;
width: 75px;
color: yellow;
/* margin does not collapse in the flexbox context */
margin: 0.75rem;
}
.item1 {
/* min-width: 50px; */
min-height: 50px;
/* adjust cross-axis position for particular element */
align-self: flex-end;
/* item will grow when the container grows */
/* item will take one part of available space */
/* flex: 1 0 0; = grow, shrink, basis */
/* flex-grow: 1; */
/* use flex basis to reset the size calc so
item2 is 2x item1, regardless of width property */
/* flex-basis: 0; */
/* change the order of the flex items */
/* although using order is not recommended as this will cause
items to be out of sync with the tab or screen reader order of the html */
/* order: 3; */
}
.item2 {
/* min-width: 60px; */
min-height: 100px;
/* item will take two parts of available space */
/* flex-grow: 2; */
/* flex-basis: 0; */
/* order: 1; */
}
.item3 {
min-height: 150px;
/* item will not shrink when the container shrinks */
/* if we have two item with flex-shrink of 1 and 3,
3 will shrink three times as fast as 1 */
flex-shrink: 0;
/* order: 2; */
}
</style>
</head>
<body>
<div class="container">
<div class="item item1">1</div>
<div class="item item2">2</div>
<div class="item item3">3</div>
</div>
<span>this is a span</span>
</body>
</html>