-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathchild-flex-shrink.html
155 lines (143 loc) · 4.52 KB
/
child-flex-shrink.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
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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
<!doctype html>
<html class="no-js" lang="">
<head>
<title>Ridiculously Easy Layouts with Flexbox</title>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href='http://fonts.googleapis.com/css?family=Lato:400,700,400italic|Architects+Daughter' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="assets/css/normalize.css/normalize.css">
<link rel="stylesheet" href="assets/css/global.css">
<link rel="stylesheet" href="assets/css/examples.css">
<link rel="stylesheet" href="assets/css/flexbox.css">
<script type="text/javascript" src="assets/js/jquery/jquery.js"></script>
<style>
.controls>span {
height: 36px;
text-align: right;
}
.examples {
justify-content: space-between;
}
.example div {
display: flex;
height: 100px;
justify-content: center;
align-items: center;
flex-basis: 0;
}
.grow-content {
display: block;
padding: 1rem 0;
}
.form-container {
display: flex;
justify-content: space-between;
}
form {
text-align: right;
margin-bottom: 2rem;
}
input {
margin-bottom: 1rem;
width: 100px;
}
</style>
</head>
<body>
<header></header>
<main>
<article>
<nav></nav>
<section>
<h2>Child - Flex Grow</h2>
<div class="form-container">
<div class="controls">
<span id="e1">
<strong>grow:</strong> 1 1 1
<br/>
<strong>shrink:</strong> 1 1 1
</span>
<span id="e2">
<strong>grow:</strong> 1 1 1
<br/>
<strong>shrink:</strong> 1 1 3
</span>
<span id="e3">
<strong>grow:</strong> 1 1 1
<br/>
<strong>shrink:</strong> 3 2 1
</span>
<span id="e4">
<strong>grow:</strong> 1 2 3
<br/>
<strong>shrink:</strong> 1 2 3
</span>
</div>
<div>
<form>
<strong>Flex Basis:</strong> <input type="text" id="flex-basis" value="auto">
<br/>
<strong>Container Width:</strong> <input type="text" id="example-width" value="auto" readonly>
</form>
</div>
</div>
<div class="example">
<div id="content1" style="flex-grow: 1"></div>
<div id="content2" style="flex-grow: 1"></div>
<div id="content3" style="flex-grow: 1"></div>
</div>
</section>
</article>
</main>
<footer></footer>
<script type="text/javascript">
$(document).ready(function( ){
reportWidths();
$('#e1').on('click',function(){
console.log('/* CSS SELECTORS */')
setFlex('1','1','1');
setFlex('2','1','1');
setFlex('3','1','1');
reportWidths();
});
$('#e2').on('click',function(){
console.log('/* CSS SELECTORS */')
setFlex('1','1','1');
setFlex('2','1','1');
setFlex('3','1','3');
reportWidths();
});
$('#e3').on('click',function(){
console.log('/* CSS SELECTORS */')
setFlex('1','1','3');
setFlex('2','1','2');
setFlex('3','1','1');
reportWidths();
});
$('#e4').on('click',function(){
console.log('/* CSS SELECTORS */')
setFlex('1','1','1');
setFlex('2','2','2');
setFlex('3','3','3');
reportWidths();
});
});
function setFlex(contentNumber,grow,shrink){
$('#content' + contentNumber).css('flex', grow + ' ' + shrink + ' ' + $('#flex-basis').val());
console.log('#content' + contentNumber + '{ flex-grow: ' + grow + '; flex-shrink: ' + shrink + '; flex-basis: ' + $('#flex-basis').val() + ' }');
}
$(window).resize(function () {
reportWidths();
});
function reportWidths(){
$('#example-width').val($('.example').width() + 'px');
$('#content1').text($('#content1').width() + 'px');
$('#content2').text($('#content2').width() + 'px');
$('#content3').text($('#content3').width() + 'px');
}
</script>
<script src="assets/js/examples.js"></script>
</body>
</html>