Skip to content

Commit 4b16882

Browse files
feat: use flex-basis instead of width and min-width
1 parent f1687f5 commit 4b16882

2 files changed

Lines changed: 13 additions & 21 deletions

File tree

index.html

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ <h3>4 columns with same width <a href="#table-of-content">↑</a></h3>
173173
<div class="flex one-one-one-one">
174174
<div>
175175
<h4>🐶 1</h4>
176-
<p><img src=" https://placedog.net/180/135?id=1" width="180" height="135" alt="🐶 1"></p>
176+
<p><img src="https://placedog.net/140/105?id=1" width="180" height="135" alt="🐶 1"></p>
177177
</div>
178178
<div>
179179
<h4>🐶 2</h4>
180-
<p><img src=" https://placedog.net/180/135?id=2" width="180" height="135" alt="🐶 2"></p>
180+
<p><img src="https://placedog.net/140/105?id=2" width="180" height="135" alt="🐶 2"></p>
181181
</div>
182182
<div>
183183
<h4>🐶 3</h4>
184-
<p><img src=" https://placedog.net/180/135?id=3" width="180" height="135" alt="🐶 3"></p>
184+
<p><img src="https://placedog.net/140/105?id=3" width="180" height="135" alt="🐶 3"></p>
185185
</div>
186186
<div>
187187
<h4>🐶 4</h4>
188-
<p><img src=" https://placedog.net/180/135?id=4" width="180" height="135" alt="🐶 4"></p>
188+
<p><img src="https://placedog.net/140/105?id=4" width="180" height="135" alt="🐶 4"></p>
189189
</div>
190190
</div>
191191

@@ -194,19 +194,19 @@ <h4>🐶 4</h4>
194194
<pre>&lt;div class="flex one-one-one-one"&gt;
195195
&lt;div&gt;
196196
&lt;h4&gt;🐶 1&lt;/h4&gt;
197-
&lt;p&gt;&lt;img src=" https://placedog.net/180/135?id=1" width="180" height="135" alt="🐶 1"&gt;&lt;/p&gt;
197+
&lt;p&gt;&lt;img src="https://placedog.net/180/135?id=1" width="180" height="135" alt="🐶 1"&gt;&lt;/p&gt;
198198
&lt;/div&gt;
199199
&lt;div&gt;
200200
&lt;h4&gt;🐶 2&lt;/h4&gt;
201-
&lt;p&gt;&lt;img src=" https://placedog.net/180/135?id=2" width="180" height="135" alt="🐶 2"&gt;&lt;/p&gt;
201+
&lt;p&gt;&lt;img src="https://placedog.net/180/135?id=2" width="180" height="135" alt="🐶 2"&gt;&lt;/p&gt;
202202
&lt;/div&gt;
203203
&lt;div&gt;
204204
&lt;h4&gt;🐶 3&lt;/h4&gt;
205-
&lt;p&gt;&lt;img src=" https://placedog.net/180/135?id=3" width="180" height="135" alt="🐶 3"&gt;&lt;/p&gt;
205+
&lt;p&gt;&lt;img src="https://placedog.net/180/135?id=3" width="180" height="135" alt="🐶 3"&gt;&lt;/p&gt;
206206
&lt;/div&gt;
207207
&lt;div&gt;
208208
&lt;h4&gt;🐶 4&lt;/h4&gt;
209-
&lt;p&gt;&lt;img src=" https://placedog.net/180/135?id=4" width="180" height="135" alt="🐶 4"&gt;&lt;/p&gt;
209+
&lt;p&gt;&lt;img src="https://placedog.net/180/135?id=4" width="180" height="135" alt="🐶 4"&gt;&lt;/p&gt;
210210
&lt;/div&gt;
211211
&lt;/div&gt;</pre>
212212
</details>

new.grid.css

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,19 @@
66
}
77

88
.flex.one-one > div {
9-
flex-grow: 1;
10-
min-width: 48%;
9+
flex-basis: 48%;
1110
}
1211

1312
.flex.one-two > div:first-child {
14-
min-width: 30%;
15-
flex-grow: 1;
13+
flex-basis: 30%;
1614
}
1715

1816
.flex.one-two > div:last-child {
19-
min-width: 65%;
20-
flex-grow: 2;
17+
flex-basis: 65%;
2118
}
2219

2320
.flex.one-one-one-one > div {
24-
min-width: 20%;
25-
flex-grow: 1;
21+
flex-basis: 25%;
2622
}
2723

2824
/* responsiveness */
@@ -37,10 +33,6 @@
3733
flex-wrap: wrap;
3834
}
3935
.flex.one-one-one-one > div {
40-
width: 40%;
41-
}
42-
43-
.flex.one-one-one-one > div img {
44-
min-width: 180px;
36+
flex-basis: 45%;
4537
}
4638
}

0 commit comments

Comments
 (0)