How to take control of Flexbox

Sdílet
Vložit
  • čas přidán 1. 05. 2024
  • If you really want to take control of Flexbox, check out my course Flexbox Simplified 👉 flexboxsimplified.com?
    🔗 Links
    ✅ The original design on Dribbble: dribbble.com/shots/23583273-H...
    ✅ My code from this video: codepen.io/kevinpowell/pen/yL...
    ✅ Flexbox Simplified: flexboxsimplified.com?
    ⌚ Timestamps
    00:00 - Introduction
    00:25 - What we are starting with
    01:18 - Understanding what happens when we use display flex
    05:00 - What flex-shrink does
    07:40 - Adding in flex-grow
    10:19 - Making things more consistent by defining the size
    #css
    --
    Come hang out with other dev's in my Discord Community
    💬 / discord
    Keep up to date with everything I'm up to
    ✉ www.kevinpowell.co/newsletter
    Come hang out with me live every Monday on Twitch!
    📺 / kevinpowellcss
    ---
    Help support my channel
    👨‍🎓 Get a course: www.kevinpowell.co/courses
    👕 Buy a shirt: teespring.com/stores/making-t...
    💖 Support me on Patreon: / kevinpowell
    ---
    My editor: VS Code - code.visualstudio.com/
    ---
    I'm on some other places on the internet too!
    If you'd like a behind the scenes and previews of what's coming up on my CZcams channel, make sure to follow me on Instagram and Twitter.
    Twitter: / kevinjpowell
    Codepen: codepen.io/kevinpowell/
    Github: github.com/kevin-powell
    ---
    And whatever you do, don't forget to keep on making your corner of the internet just a little bit more awesome!

Komentáře • 92

  • @Wakedaddy87
    @Wakedaddy87 Před měsícem +56

    One thing you said here I had never thought about was the fact that flexbox is controlled inside-->out, but grid is controlled outside-->in. That makes a lot of sense and actually clarifies a lot more of this. Thanks for all of the amazing videos!

    • @Allformyequine
      @Allformyequine Před měsícem +1

      I noticed that too, that's a great easy concept to keep in mind! Super!

  • @satadhi
    @satadhi Před dnem

    Sir, i would like to confess that you are simply the best.

  • @lukedorny
    @lukedorny Před měsícem +8

    Great overview. Thanks, Kevin.

  • @KeithTharp
    @KeithTharp Před měsícem

    Excellent!! I've been avoiding flexbox for so long, this helps a ton

  • @kerrykreiter445
    @kerrykreiter445 Před měsícem

    Thank you Kevin! “Content is king in flexbox” is going to stick with me. This video really helped me get a much better understanding of flex shrink and grow and how they can be used in many layouts. Thank you for developing and sharing such useful content!

  • @jfftck
    @jfftck Před měsícem +8

    I think the issue with people understanding flexbox is due to them not working with HTML tables, because, if they had, they’d see how both use a similar - if not the same - resizing behavior. Every time I use flexbox, I think of them as defaulting to being like a table row - where it can only have one row - and, just like tables, you have to define the behavior you want.
    This proves that the algorithm for tables were a good solution for layout, but breaking it up into two layout properties (flexbox and grid) gave us much more control over that algorithm. This is what CSS is about, I think all the interactive parts of CSS could be turned into a new language and that might make that simpler. It’s as though things like animations, transitions, and transforms are all complex due to having to fit into the CSS design specifications. I understand these very well, but find the syntax is the most complex part of it, since CSS was designed for layout and styling.

  • @pedromenezes4013
    @pedromenezes4013 Před měsícem

    thanks! you're always helping demystify tricky behavior!

  • @CHANDRASHEKAR-ox4qt
    @CHANDRASHEKAR-ox4qt Před měsícem

    felt like reading css manual while watching the video thanking you sir!🙏🙏

  • @dongbinkim3773
    @dongbinkim3773 Před měsícem

    Feel like finally getting to Flexbox. Thank you!

  • @rrenildopereiraa
    @rrenildopereiraa Před měsícem

    amazing stuff! this will help my projects a lot!

  • @magoxxii
    @magoxxii Před měsícem +2

    Every time I have an issue to solve, you upload a video related! its so great! thanks for such amazing content always!

    • @StephenRayner
      @StephenRayner Před 17 dny

      Same, finally digging deep into CSS as sick of being crap at it. 15 years experience, AWS, python, typescript, C#, React, React Native blah blah…
      But CSS every time I am just fighting it. Need to really learn more beyond box model, cascading, inheritance.

  • @yatskanych_oleksandr
    @yatskanych_oleksandr Před měsícem +2

    That's why i prefer to use grid instead of flex. Thanks for useful content as usually

  • @jan.kowalski
    @jan.kowalski Před měsícem

    Excellent explanation. Thanks!

  • @jagonza2000
    @jagonza2000 Před měsícem +1

    love it! 👏

  • @jesisadhikari
    @jesisadhikari Před 25 dny

    Really saved my time dude, thanks!

  • @einatblackrose
    @einatblackrose Před měsícem

    That's very helpful. Thank you

  • @vladpopescu2004
    @vladpopescu2004 Před měsícem +1

    Hello Kevin, your link for flexbox simplified has left the analytics parameters out. Thank you for the consistently good content!

  • @Lucifer-vz4hg
    @Lucifer-vz4hg Před měsícem

    man is saving us

  • @mendosis
    @mendosis Před měsícem +6

    i wouldn't bother guessing or forcing the size of the middle part
    you should align images to avoid inconsistencies (which in my opinion is the best place to set flex-shrink to 0) and send metaboxes to the right-hand side (either with automargin or with flex-grow in the middle). then you can let the latter two play or fix the size of the metabox if your design is grid based

  • @simon-off
    @simon-off Před měsícem

    I'm gonna try to use flex some more when it's suitable. Grid is just so good though 😅
    Great video! Thanks Kevin

  • @OCEMTechZone
    @OCEMTechZone Před měsícem +1

    Great Sir 🎉

  • @ofadiman
    @ofadiman Před měsícem +2

    Flexbox is taking control of my life 😳

  • @atwarwithlife
    @atwarwithlife Před 28 dny

    you're the css goat.

  • @pinnaclewd
    @pinnaclewd Před měsícem +29

    Im sticking with grid.....its all I need.

    • @Julie-gh5ir
      @Julie-gh5ir Před měsícem

      Is there the same kind of video, but with grids ? I avoid learning it for so long.... Kevin seems to be the good teacher for me.

    • @ErikBlomqvistSwe
      @ErikBlomqvistSwe Před měsícem

      @@Julie-gh5ir not the same kind, since there's so much more to cover with grid, but just go to his channel and search for "grid" and you'll find tons of helpful material!

    • @RickBeacham
      @RickBeacham Před měsícem

      You may need to learn Flex-box especially when many websites are using it instead of the wonderful GRID... :)

    • @Julie-gh5ir
      @Julie-gh5ir Před měsícem

      I already know flexbox.@@RickBeacham

    • @StephenRayner
      @StephenRayner Před 17 dny +1

      I can’t recall why but there are some situations where flex is more suitable than grid.

  • @moritzdeiaco2798
    @moritzdeiaco2798 Před měsícem

    The og border lime hack! Nice video

  • @yogibarista2818
    @yogibarista2818 Před měsícem

    I tend to use flex-basis: to control the "fixed-size" elements

  • @reneeschke
    @reneeschke Před měsícem

    Pleeease a Video explicitly exploring flex basis in column direction. Shrink and grow in column works conceptually so much different as you always (usually...) have room to scroll and therefore no limiting height

  • @GerritforBazeja
    @GerritforBazeja Před měsícem

    this is nice to know. Tnx

  • @tutestheking7838
    @tutestheking7838 Před měsícem +6

    most of the time I use grid just because it just does what i want, but using flex-shrink/grow/basis seems like a good option in some cases.
    Thanks for the content Kevin

    • @chrisstucker1813
      @chrisstucker1813 Před měsícem +1

      Both are very useful. It made more sense to me the moment I realised flex sizes are determined by the children content whereas grid is more about the parent. That’s why grid feels more comfortable, because you’re not worrying so much about the children content. In grid, the children abide the parent; in flex, the children control the parent!

  • @sjd_style
    @sjd_style Před 18 dny

    Amazing tnx

  • @ToyotaCharlie
    @ToyotaCharlie Před měsícem

    this episode was very Canadian with all the "outs" ❤️🇨🇦😉

  • @amanuelelhanan4716
    @amanuelelhanan4716 Před měsícem +1

    This statement opened my eyes Kevin, 4:20

  • @tomiekk6255
    @tomiekk6255 Před měsícem +1

    This is super interesting! Personally from what you showed I think I would use Flexbox over grid in such situation, are there any pros of using grid in this particular example?

  • @MartinDoudoroffLLC
    @MartinDoudoroffLLC Před měsícem

    Thanks!

  • @m12652
    @m12652 Před měsícem

    Thanks... again 👍 Anyone else notice Chrome is not handling anchor positioning/popovers properly since a couple of updates back? Mine are always opening top left regardless of where the element they are anchored to is.

  • @abhim6380
    @abhim6380 Před měsícem

    Bought the course. Any plans to make grid simplified?

  • @rayyanabdulwajid7681
    @rayyanabdulwajid7681 Před měsícem

    Guys, just remember how to use display flex, justify content center, align items center, flex wrap: wrap, flex shrink, justify content space between, flex 1 ,etc

  • @ClarkSell
    @ClarkSell Před měsícem +1

    THAT HOODIE!!!

  • @haidubogdan8712
    @haidubogdan8712 Před měsícem

    recently I needed to solve styling for columns with stacked blocks.
    The solution was not grid, and not display flex but column-count : nr.
    I'm interested if you can make a video about column-count, column-span .... css

  • @percurious
    @percurious Před měsícem

    Talking about flex laxouts - just stumbled upon a problem where someone was a bit to loose with things - can you think of any usecase where you would want a flex-direction: column; combined with a flex-wrap: wrap; ? 🤔

  • @RohitKumar-xs3wh
    @RohitKumar-xs3wh Před 4 dny

    nice

  • @MrJettann
    @MrJettann Před měsícem +3

    If I need consistent layout, usually I'm using grid

    • @KevinPowell
      @KevinPowell  Před měsícem +3

      yeah, grid is probably an easier choice here, and where I'd have gone first, which I sort of alluded to druing the video, but sometimes it's nice to know how to wrangle flexbox a little.

  • @quark2012
    @quark2012 Před měsícem

    How many times I fight with this problem :) Thanks

  • @vilijanac
    @vilijanac Před měsícem

    It would be nice if would resize and flex different images to a max-with.

  • @JoelGallant236
    @JoelGallant236 Před měsícem +2

    Why not space-between?

  • @GauravKumar-qe7iu
    @GauravKumar-qe7iu Před měsícem

    did display: grid; and grid-template-columns: auto 1fr auto; works same in this case?

  • @proteus1
    @proteus1 Před měsícem

    Grid and Flex both have their advantages.If I was programming Grid, would make a rule for cloning rows. Grid row-d to copy parent. D for duplication of parent. No brainer to me. Why make life complicated.

  • @djamaatul
    @djamaatul Před 13 dny

    im using flex-1 instead flex-grow-1, when use case use flex-1 vs flex-grow ?

  • @LokiDaFerret
    @LokiDaFerret Před měsícem +2

    This video is a good example why you don't use flex. Grid is the right tool for the job. At least in this layout.
    However you missed a great opportunity to explain flex shrink and grow better. Because they are a ratio. If they are all set to one then your ratio is 1:1. If one of them is set to 2 then your ratio is 2:1 etc. In other words the speed at which something grows and shrinks relative to its siblings can be controlled. A missed opportunity 😂

  • @toptravelingoffers7666
    @toptravelingoffers7666 Před měsícem +3

    Why don't you add your videos in playlist. example this video. It also becomes very difficult to find specific videos within many videos so having a playlist or play store serial would be very helpful.
    I just started web dev[CSS] and I love your videos so I have a request for you to make a complete serial playlist for beginners.
    Your videos are amazing and the playlists are beautiful but I don't know which playlist to start with,, so please make a videos to guide beginners step by step serial playlists🙏

    • @KevinPowell
      @KevinPowell  Před měsícem +1

      Once you get past the very basics, which I have a playlist on, it can be hard to organize things after that because it often comes down to what you're trying to accomplish, but I'll see what I can do 😊

  • @Julie-gh5ir
    @Julie-gh5ir Před měsícem

    What are the differences between flex-basis and width ? I always use width... But perhaps it is not the better solution ?

  • @safariknight3239
    @safariknight3239 Před měsícem

    I swear I only understand this because of Kevin

  • @JimKernix
    @JimKernix Před měsícem

    at 3:15 you clicked and dragged each image in the article.hotle-listing and a faded out version of the photos was visible until you released your mouse. What is that? How does the browser enable that? I know it's not related to your video but that is an interesting behavior...

  • @srinathsagar4736
    @srinathsagar4736 Před měsícem

    make a video on
    GRID

  • @sumitsinha995
    @sumitsinha995 Před měsícem

    He Kevin there must be starter code .Like there is full code availble.

  • @Techgether
    @Techgether Před měsícem

    when is the appropriate situation when we use width vs flex basis? i still cant grasp the concept of flex basis :/ do u have a video on this?

    • @brickslabel
      @brickslabel Před měsícem

      Flex-basis is only an option if the item is a flex-child, and is best when the children are of varying sizes and are ok with their widths being more fluid. Width is when you need a fixed size/are not flexible and not in a Flexbox layout; it's more precise.

    • @Techgether
      @Techgether Před měsícem

      @MrTicketeer understand the purpose of flex basis, but unclear how to use it..

    • @brickslabel
      @brickslabel Před 29 dny

      @@Techgether that's the point I was trying to get across though; it depends on your needs. If you have children of varying sizes and want to set a min-width they should all be without saying "MINIMUM" width and making them be that width, you can offer a "basis" which is flexible: be that width if you can, but shrink if needbe. You apply it to the children. Maybe I'm missing what you are asking when you say "how" to use it? Your original comment asked "when"; what do you mean by "how"?

    • @Techgether
      @Techgether Před 28 dny

      @MrTicketeer yes I understand the purpose of flex basis better now. How to use it is my 2nd question and I meant like I don't understand the syntax or what unit to use under flex basis

  • @OghamTheBold
    @OghamTheBold Před 18 dny

    Lack of understanding hints at hidden algorithm

  • @RickBeacham
    @RickBeacham Před měsícem

    Why did you stop using Firefox? :(

  • @AlThePal78
    @AlThePal78 Před měsícem

    almost want to use tables lol

  • @gE0013
    @gE0013 Před měsícem +1

    With the introduction of "grid", I think "flex" is going to be used way less. Basically, if you have a pile of elements, you are probably going to use "grid" because you want to keep things aligned.

    • @DeadShotFPS
      @DeadShotFPS Před měsícem

      Not at all. As Kevin says in this video and many others, Flexbox is most useful in cases where you want each item’s size to be determined by its content.

    • @gE0013
      @gE0013 Před měsícem

      @@DeadShotFPS I don't get your point: since is very common that piled elements have different content, if you use flex it would be harder to make them aligned. And the reason is exactly what you said.

  • @SmileyJack.
    @SmileyJack. Před měsícem

    10:14 E
    O_O -> --_--

  • @MegaPixel404
    @MegaPixel404 Před měsícem

    16 min video that could be explained in 3, less repeats and actual info repeated one last time starts at 11:00 just define your widths and make 1 grow, breakpoint when needed

  • @planesrift
    @planesrift Před měsícem

    Just do everything on canvas /s

  • @DeepakKumar-ob6ps
    @DeepakKumar-ob6ps Před měsícem

    Same price without breakfast? 😂

  • @NoToBusinessCasual
    @NoToBusinessCasual Před měsícem +1

    I hate Flexbox. Completely unreliable and undependable. Rubbish concept.

  • @user-ouss
    @user-ouss Před 27 dny

    Please don't speak fast

  • @user-ze7nw9ud7m
    @user-ze7nw9ud7m Před měsícem

    I don't use flexbox, because it feels like an old man trying to learn teenager's slang. Disgusting.
    Why it's not "grid" or something?

  • @Pareshbpatel
    @Pareshbpatel Před 9 dny

    Nice one, Kevin. thanks.
    {2024-04-23}