Watching all other videos, I wondered why the width of one is not in proportion to the other. You made it so clear that the extra room is divided in that proportion. Awesome! Two questions: 1. What is flex-basis when flex:1 is used? 2. What is the difference between using width vs flex-basis on a flex item?
i have watched lots of youtube videos about flex-grow and shrink., i really didn't understand them properly after i watched this it's gave the clear concept about flex-grow and flex-shrink.Thank you very much Wes Bos
Great explanation! I now understand more about these properties, thank you! I gotta note that the intro is very loud and your voice is very low, but this video is 7 y o so might have changed.
Good tutorial. You can also enable the browser's responsive "toggle device toolbar" tool e.g. Chrome to resize the frame instead of resizing your entire browser window.
Pretty sure all the downvotes are the result of that intro. I was so annoyed... Started to wonder if there is something seriously wrong with me to find it that annoying; but then I saw your comment.
Hi Wes, can you please use fractions to express how much an element is giving away of its width when using flex-shrink? I think I don’t get it. You use flex-basis:400px for both .box1 and .box2. So, when the container is 800px wide, each box is 400px wide. Then you use flex-grow:10 for .box1 and flex-grow:1 for .box2. So, when the container gets wider than 800px the extra room will get split between the elements using the ratio we set for flex-grow. My understanding is that .box1 gets 10/11 of free space and .box2 gets 1/11. So yes, .box1 gets 10x more extra space than .box2. But how does this work with flex-shrink? We used the same values for flex-shrink as for flex-grow, but obviously .box1 is not giving away 10/11 of its width when the container gets below 800px. Thanks!
I think I got it, but I am not sure if I'm right. I think that if the container gets for example 700px wide the .box1 and 2 miss 100px, they just can't be 400px each any more. So, they have to split the 100px using the ratio above, meaning .box1 will be narrower by 100*10/11~90.91px and .box2 will be narrower by 100*1/11~9.09. The new width of .box1 will be 400-90.91=309.09px and the width of .box2 will be 400-9.09=390.91px. Now .box1 and .box2 (309.09+390.91=700) exactly fit 700px wide container. Can somebody confirm my theory? :D
why is there bullshit like if you are in the 10th level div you can't set it to use the remaining space but need to put display flex on every level of div above it? Shouldn't immediate div be enough?
+Barbudo view port dimensions available in the chrome store here: chrome.google.com/webstore/detail/viewport-dimensions/kchdfagjljmhgapoonapmfngpadcjkhk/related?hl=en-US
I think this is not completele well explained. Why? Because when you give flex-grow or flex-shrink to an element you do not make 'x' times bigger than the other one, you are just using 'THE AVAILABLE SPACE', and dividing it in many spaces as you have given to the summary of all the elements, and from this point the browser gives the size to every element according with the number of flex-grow o shrink that you gave to it every single element. (My english is not good enought sorry). Bless!