forked from learning-zone/css-basics
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrid-flexbox-layout.html
78 lines (72 loc) · 2.08 KB
/
grid-flexbox-layout.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
<!DOCTYPE html>
<html>
<head>
<title>Grid vs Flexbox Layout</title>
</head>
<style>
/**
1.Flexbox was designed for layout in one dimension - either a row or a column.
Grid was designed for two-dimensional layout - rows, and columns at the same time.
2.CSS Grid’s approach is layout-first while Flexbox’ approach is content-first.
3.Flexbox layout is most appropriate to small-scale layouts, while the Grid layout
is intended for larger scale layouts which aren’t linear in their design.
**/
/* Grid layout */
.row {
display: grid;
grid-template-columns: auto auto auto;
background-color: #2196f3;
padding: 5px;
}
.col-item {
background-color: rgba(255, 255, 255, 0.8);
border: 1px solid rgba(0, 0, 0, 0.8);
padding: 10px;
font-size: 30px;
text-align: center;
}
/* Flexbox layout */
.wrapper {
border: 2px solid #f76707;
border-radius: 5px;
background-color: #fff4e6;
}
.wrapper > div {
border: 2px solid #ffa94d;
border-radius: 5px;
background-color: #ffd8a8;
padding: 1em;
color: #d9480f;
}
.wrapper {
display: flex;
width: 500px;
flex-wrap: wrap;
}
.wrapper > div {
flex: 1 1 150px;
}
</style>
<body>
<p><h1>Grid Layout Example<hr/></h1></p>
<div class="row">
<div class="col-item">Column - 1</div>
<div class="col-item">Column - 2</div>
<div class="col-item">Column - 3</div>
<div class="col-item">Column - 1</div>
<div class="col-item">Column - 2</div>
<div class="col-item">Column - 3</div>
<div class="col-item">Column - 1</div>
<div class="col-item">Column - 2</div>
<div class="col-item">Column - 3</div>
</div>
<p><h1><br/>Flexbox Layout Example<hr/></h1></p>
<div class="wrapper">
<div>One</div>
<div>Two</div>
<div>Three</div>
<div>Four</div>
<div>Five</div>
</div>
</body>
</html>