Skip to content

Commit 8b1ec34

Browse files
committed
Adding a flex gaps example
1 parent 54b5f33 commit 8b1ec34

File tree

1 file changed

+148
-0
lines changed

1 file changed

+148
-0
lines changed

box-alignment/flexbox/gap.html

Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Flexbox Alignment: gaps</title>
7+
8+
<style>
9+
body {
10+
font: 1.2em Helvetica, Arial, sans-serif;
11+
margin: 20px;
12+
padding: 0;
13+
}
14+
15+
textarea {
16+
font-family: monospace;
17+
display: block;
18+
margin-bottom: 10px;
19+
background-color: #F4F7F8;
20+
border: none;
21+
border-left: 6px solid #558ABB;
22+
color: #4D4E53;
23+
width: 90%;
24+
max-width: 700px;
25+
padding: 10px 10px 0px;
26+
font-size: 90%;
27+
}
28+
29+
textarea:nth-of-type(1) {
30+
height: 170px
31+
}
32+
33+
textarea:nth-of-type(2) {
34+
height: 160px
35+
}
36+
37+
.playable-buttons {
38+
text-align: right;
39+
width: 90%;
40+
max-width: 700px;
41+
padding: 5px 10px 5px 26px;
42+
font-size: 100%;
43+
}
44+
45+
section {
46+
width: 90%;
47+
max-width: 700px;
48+
border: 1px solid #4D4E53;
49+
border-radius: 2px;
50+
padding: 10px 14px 10px 10px;
51+
margin-bottom: 10px;
52+
}
53+
54+
section input {
55+
display: block;
56+
margin: 5px;
57+
}
58+
59+
.box {
60+
width: 500px;
61+
border: 2px dotted rgb(96, 139, 168);
62+
}
63+
64+
.box>* {
65+
padding: 20px;
66+
border: 2px solid rgb(96, 139, 168);
67+
border-radius: 5px;
68+
background-color: rgba(96, 139, 168, .2);
69+
}
70+
</style>
71+
<style class="editable">
72+
.box {
73+
display: flex;
74+
flex-wrap: wrap;
75+
row-gap: 10px;
76+
column-gap: 2em;
77+
}
78+
79+
.box > * {
80+
flex: 1;
81+
}
82+
</style>
83+
</head>
84+
85+
<body>
86+
<section>
87+
<div class="box">
88+
<div>One</div>
89+
<div>Two</div>
90+
<div>Three</div>
91+
<div>Four</div>
92+
<div>Five</div>
93+
<div>Six</div>
94+
</div>
95+
96+
</section>
97+
<textarea class="playable-css">
98+
.box {
99+
display: flex;
100+
flex-wrap: wrap;
101+
row-gap: 10px;
102+
column-gap: 2em;
103+
}
104+
105+
.box > * {
106+
flex: 1;
107+
}
108+
</textarea>
109+
<textarea id="code" class="playable-html">
110+
<div class="box">
111+
<div>One</div>
112+
<div>Two</div>
113+
<div>Three</div>
114+
<div>Four</div>
115+
<div>Five</div>
116+
<div>Six</div>
117+
</div>
118+
</textarea>
119+
<div class="playable-buttons">
120+
<input id="reset" type="button" value="Reset">
121+
</div>
122+
</body>
123+
<script>
124+
var section = document.querySelector('section');
125+
var editable = document.querySelector('.editable');
126+
var textareaHTML = document.querySelector('.playable-html');
127+
var textareaCSS = document.querySelector('.playable-css');
128+
var reset = document.getElementById('reset');
129+
var htmlCode = textareaHTML.value;
130+
var cssCode = textareaCSS.value;
131+
132+
function fillCode() {
133+
editable.innerHTML = textareaCSS.value;
134+
section.innerHTML = textareaHTML.value;
135+
}
136+
137+
reset.addEventListener('click', function () {
138+
textareaHTML.value = htmlCode;
139+
textareaCSS.value = cssCode;
140+
fillCode();
141+
});
142+
143+
textareaHTML.addEventListener('input', fillCode);
144+
textareaCSS.addEventListener('input', fillCode);
145+
window.addEventListener('load', fillCode);
146+
</script>
147+
148+
</html>

0 commit comments

Comments
 (0)