Skip to content

Commit 6bc4ea6

Browse files
committed
adding the simple example for the overview page
1 parent 4ecfebb commit 6bc4ea6

File tree

1 file changed

+138
-0
lines changed

1 file changed

+138
-0
lines changed

flexbox/basics/simple-example.html

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>A simple example of Flexbox</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+
display: block;
17+
margin-bottom: 10px;
18+
height: 160px;
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: 80px
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+
border: 2px solid rgb(96, 139, 168);
66+
border-radius: 5px;
67+
background-color: rgba(96, 139, 168, .2);
68+
padding: 10px;
69+
}
70+
</style>
71+
<style class="editable">
72+
.box {
73+
display: flex;
74+
justify-content: space-between;
75+
}
76+
</style>
77+
</head>
78+
79+
<body>
80+
<section>
81+
<div class="box">
82+
<div>One</div>
83+
<div>Two</div>
84+
<div>Three
85+
<br>has
86+
<br>extra
87+
<br>text
88+
</div>
89+
</div>
90+
91+
</section>
92+
<textarea class="playable-css">
93+
.box {
94+
display: flex;
95+
justify-content: space-between;
96+
}
97+
</textarea>
98+
<textarea id="code" class="playable-html">
99+
<div class="box">
100+
<div>One</div>
101+
<div>Two</div>
102+
<div>Three
103+
<br>has
104+
<br>extra
105+
<br>text
106+
</div>
107+
</div>
108+
</textarea>
109+
<div class="playable-buttons">
110+
<input id="reset" type="button" value="Reset">
111+
</div>
112+
</body>
113+
<script>
114+
var section = document.querySelector('section');
115+
var editable = document.querySelector('.editable');
116+
var textareaHTML = document.querySelector('.playable-html');
117+
var textareaCSS = document.querySelector('.playable-css');
118+
var reset = document.getElementById('reset');
119+
var htmlCode = textareaHTML.value;
120+
var cssCode = textareaCSS.value;
121+
122+
function fillCode() {
123+
editable.innerHTML = textareaCSS.value;
124+
section.innerHTML = textareaHTML.value;
125+
}
126+
127+
reset.addEventListener('click', function () {
128+
textareaHTML.value = htmlCode;
129+
textareaCSS.value = cssCode;
130+
fillCode();
131+
});
132+
133+
textareaHTML.addEventListener('input', fillCode);
134+
textareaCSS.addEventListener('input', fillCode);
135+
window.addEventListener('load', fillCode);
136+
</script>
137+
138+
</html>

0 commit comments

Comments
 (0)