-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path12-Flexbox (Complete Guide).html
More file actions
113 lines (100 loc) · 2.47 KB
/
12-Flexbox (Complete Guide).html
File metadata and controls
113 lines (100 loc) · 2.47 KB
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>12-Flexbox (Complete Guide)</title>
<style>
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
/* ================= Flexbox Basic Example ================= */
.container {
border: 2px solid black;
padding: 20px;
display: flex;
flex-direction: row;
justify-content: space-evenly;
align-items: stretch;
height: 300px;
}
.box {
background: lightblue;
padding: 20px;
border: 1px solid black;
font-size: 20px;
}
.box:nth-child(2) {
align-self: center;
}
/* ================= Navbar Example ================= */
.nav {
display: flex;
justify-content: space-between;
align-items: center;
padding: 20px;
border: 1px solid black;
margin-top: 30px;
}
.nav ul {
display: flex;
list-style: none;
gap: 20px;
}
/* ================= Cards Example ================= */
.cards {
border: 2px solid black;
display: flex;
width: 500px;
gap: 20px;
margin: 30px;
/* flex-wrap: wrap; <-- enable this when teaching wrap */
}
.card {
background: rgb(61, 132, 141);
width: 200px;
height: 100px;
color: white;
display: flex;
justify-content: center;
align-items: center;
}
/* ================= Perfect Center Example ================= */
.center-box {
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
}
</style>
</head>
<body>
<!-- Flex Container Example -->
<div class="container">
<div class="box">Box 1</div>
<div class="box">Box 2</div>
<div class="box">Box 3</div>
</div>
<!-- Navbar Example -->
<header class="nav">
<h2>Logo</h2>
<ul>
<li>Home</li>
<li>Services</li>
<li>Contact</li>
</ul>
</header>
<!-- Cards Layout Example -->
<div class="cards">
<div class="card">Card 1</div>
<div class="card">Card 2</div>
<div class="card">Card 3</div>
</div>
<!-- Perfect Center Example -->
<div class="center-box">
<p>Hello</p>
</div>
</body>
</html>