Skip to content

Commit d0bd260

Browse files
committed
Add Give Elements The Same Width With Flexbox as a css til
1 parent 3cd0682 commit d0bd260

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ and pairing with smart people at Hashrocket.
99

1010
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1111

12-
_879 TILs and counting..._
12+
_880 TILs and counting..._
1313

1414
---
1515

@@ -99,6 +99,7 @@ _879 TILs and counting..._
9999
- [Circular Icons With A Massive Border Radius](css/circular-icons-with-a-massive-border-radius.md)
100100
- [Create A Pulsing Background With CSS Animation](css/create-a-pulsing-background-with-css-animation.md)
101101
- [Dry Up SCSS With Mixins](css/dry-up-scss-with-mixins.md)
102+
- [Give Elements The Same Width With Flexbox](css/give-elements-the-same-width-with-flexbox.md)
102103
- [Lighten And Darken With CSS Brightness Filter](css/lighten-and-darken-with-css-brightness-filter.md)
103104
- [Lighten And Darken With SCSS](css/lighten-and-darken-with-scss.md)
104105
- [Make A Block Of Text Respect New Lines](css/make-a-block-of-text-respect-new-lines.md)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# Give Elements The Same Width With Flexbox
2+
3+
By default, a row of elements in a basic flex container are going to have
4+
dynamic widths that accommodate their contents. This may not be desirable if
5+
you're going for a uniform look. You could give all child elements a fixed
6+
width (e.g. `width: 100px`), but that loses out on the _flexibility_ of a
7+
flexbox layout.
8+
9+
You can instead give all child elements a uniform and flexible width using the
10+
`flex` property.
11+
12+
```css
13+
.flex-container {
14+
display: flex;
15+
}
16+
17+
.flex-child {
18+
flex: 1;
19+
}
20+
```
21+
22+
This value is a relative ratio. If all children of the flex container have the
23+
same `flex` value (i.e. `1`), then they will all be equally sized and that size
24+
will adjust as the width of the flex container changes.
25+
26+
[source](https://css-tricks.com/the-thought-process-behind-a-flexbox-layout/)

0 commit comments

Comments
 (0)