flex or flex-grow | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

flex or flex-grow

i am using a flex to adjust a width for these element; main, .aside1, .aside2. a page comes as i expected. as i know flex is a shorthand for flex-grow, flex-shrink, and flex-basis. because a first shorthand for a flex is a flex-grow, so i try to change a flex to flex-grow to makes width adjustment for some elements. hoping it will give a same results, but a results are not as expected. This is my code: https://code.sololearn.com/WR0hbwfhR2eB/?ref=app This is how it looks when flex change to flex-grow: https://i.ibb.co/PZsHSM7/flex-or-flex-grow.png I change flex with flex-grow : https://i.ibb.co/PrbZdXg/flexeded.png

5th Sep 2020, 4:19 PM
Dec Fathani
Dec Fathani - avatar
2 Answers
+ 4
Good question https://developer.mozilla.org/en-US/docs/Web/CSS/flex#%3C'flex-grow'%3E One-value syntax: the value must be one of: a <number>: In this case it is interpreted as flex: <number> 1 0; the <flex-shrink> value is assumed to be 1 and the <flex-basis> value is assumed to be 0. So, Add flex-shrink: 1; and flex-basis: 0; and you should see outcome same as flex: 1; https://code.sololearn.com/Wko1dtuqMdbM/?ref=app
5th Sep 2020, 5:02 PM
Gordon
Gordon - avatar
+ 1
Gordon i think flex-grow, flex-shrink and flex-basis doesn't always works if written as single line. It's 'safer' using a flex shorthand i think Thanks for replying n solutions suggestions
7th Sep 2020, 6:13 AM
Dec Fathani
Dec Fathani - avatar