Skip to content

Commit b35c993

Browse files
committed
ratios along the main axis
1 parent 9dd0f24 commit b35c993

7 files changed

+883
-0
lines changed

flexbox/index.html

+10
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,15 @@ <h2>Order</h2>
5656
<li><a href="order/negative-order.html">Using negative values for order</a></li>
5757
<li><a href="order/usecase-order.html">A usecase for the order property</a></li>
5858
</ol>
59+
60+
<h2>Ratios on the main axis</h2>
61+
<ol>
62+
<li><a href="ratios/flex-basis.html">The flex-basis property</a></li>
63+
<li><a href="ratios/flex-grow.html">The flex-grow property</a></li>
64+
<li><a href="ratios/flex-grow-ratios.html">Ratios and the flex-grow property</a></li>
65+
<li><a href="ratios/flex-shrink.html">The flex-shrink property</a></li>
66+
<li><a href="ratios/flex-shrink-min-content.html">min-content sizing and the flex-shrink property</a></li>
67+
<li><a href="ratios/flex-shrink-ratios.html">Ratios and the flex-shrink property</a></li>
68+
</ol>
5969
</body>
6070
</html>

flexbox/ratios/flex-basis.html

+145
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Flexbox Ratios on the main axis: flex-basis</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+
background-color: #F4F7F8;
19+
border: none;
20+
border-left: 6px solid #558ABB;
21+
color: #4D4E53;
22+
width: 90%;
23+
max-width: 700px;
24+
padding: 10px 10px 0px;
25+
font-size: 90%;
26+
}
27+
28+
textarea:nth-of-type(1) {
29+
height: 240px
30+
}
31+
32+
textarea:nth-of-type(2) {
33+
height: 90px
34+
}
35+
36+
.playable-buttons {
37+
text-align: right;
38+
width: 90%;
39+
max-width: 700px;
40+
padding: 5px 10px 5px 26px;
41+
font-size: 100%;
42+
}
43+
44+
section {
45+
width: 90%;
46+
max-width: 700px;
47+
border: 1px solid #4D4E53;
48+
border-radius: 2px;
49+
padding: 10px 14px 10px 10px;
50+
margin-bottom: 10px;
51+
}
52+
53+
section input {
54+
display: block;
55+
margin: 5px;
56+
}
57+
58+
.box > * {
59+
border: 2px solid rgb(96, 139, 168);
60+
border-radius: 5px;
61+
background-color: rgba(96, 139, 168, .2);
62+
}
63+
64+
.box {
65+
display: flex;
66+
width: 500px;
67+
border: 2px dotted rgb(96, 139, 168);
68+
}
69+
</style>
70+
71+
<style class="editable">
72+
.box {
73+
display: flex;
74+
}
75+
76+
.box :first-child {
77+
width: 150px;
78+
}
79+
80+
.box > * {
81+
flex: 0 0 auto;
82+
}
83+
84+
85+
</style>
86+
</head>
87+
88+
<body>
89+
<section>
90+
<div class="box">
91+
<div>One</div>
92+
<div>Two</div>
93+
<div>Three</div>
94+
</div>
95+
</section>
96+
<textarea class="playable-css">
97+
.box {
98+
display: flex;
99+
}
100+
101+
.box :first-child {
102+
width: 150px;
103+
}
104+
105+
.box > * {
106+
flex: 0 0 auto;
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>
115+
</textarea>
116+
<div class="playable-buttons">
117+
<input id="reset" type="button" value="Reset">
118+
</div>
119+
</body>
120+
<script>
121+
var section = document.querySelector('section');
122+
var editable = document.querySelector('.editable');
123+
var textareaHTML = document.querySelector('.playable-html');
124+
var textareaCSS = document.querySelector('.playable-css');
125+
var reset = document.getElementById('reset');
126+
var htmlCode = textareaHTML.value;
127+
var cssCode = textareaCSS.value;
128+
129+
function fillCode() {
130+
editable.innerHTML = textareaCSS.value;
131+
section.innerHTML = textareaHTML.value;
132+
}
133+
134+
reset.addEventListener('click', function () {
135+
textareaHTML.value = htmlCode;
136+
textareaCSS.value = cssCode;
137+
fillCode();
138+
});
139+
140+
textareaHTML.addEventListener('input', fillCode);
141+
textareaCSS.addEventListener('input', fillCode);
142+
window.addEventListener('load', fillCode);
143+
</script>
144+
145+
</html>

flexbox/ratios/flex-grow-ratios.html

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

0 commit comments

Comments
 (0)