How to take control of Flexbox

Поделиться
HTML-код
  • Опубликовано: 31 май 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 RUclips 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!

Комментарии • 100

  • @Wakedaddy87
    @Wakedaddy87 2 месяца назад +88

    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 2 месяца назад +1

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

  • @kerrykreiter445
    @kerrykreiter445 2 месяца назад +1

    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!

  • @KeithTharp
    @KeithTharp 2 месяца назад

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

  • @magoxxii
    @magoxxii 2 месяца назад +5

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

    • @StephenRayner
      @StephenRayner Месяц назад

      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.

  • @lukedorny
    @lukedorny 2 месяца назад +8

    Great overview. Thanks, Kevin.

  • @pedromenezes4013
    @pedromenezes4013 2 месяца назад

    thanks! you're always helping demystify tricky behavior!

  • @jfftck
    @jfftck 2 месяца назад +9

    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.

  • @yatskanych_oleksandr
    @yatskanych_oleksandr 2 месяца назад +4

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

  • @dongbinkim3773
    @dongbinkim3773 2 месяца назад

    Feel like finally getting to Flexbox. Thank you!

  • @rrenildopereiraa
    @rrenildopereiraa 2 месяца назад

    amazing stuff! this will help my projects a lot!

  • @satadhi
    @satadhi Месяц назад

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

  • @mendosis
    @mendosis 2 месяца назад +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

  • @CHANDRASHEKAR-ox4qt
    @CHANDRASHEKAR-ox4qt 2 месяца назад

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

  • @vladpopescu2004
    @vladpopescu2004 2 месяца назад +1

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

  • @jesisadhikari
    @jesisadhikari Месяц назад

    Really saved my time dude, thanks!

  • @jan.kowalski
    @jan.kowalski 2 месяца назад

    Excellent explanation. Thanks!

  • @jagonza2000
    @jagonza2000 2 месяца назад +1

    love it! 👏

  • @simon-off
    @simon-off 2 месяца назад

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

  • @pinnaclewd
    @pinnaclewd 2 месяца назад +29

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

    • @Julie-gh5ir
      @Julie-gh5ir 2 месяца назад

      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 2 месяца назад

      @@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 2 месяца назад

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

    • @Julie-gh5ir
      @Julie-gh5ir 2 месяца назад

      I already know flexbox.@@RickBeacham

    • @StephenRayner
      @StephenRayner Месяц назад +1

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

  • @scott-richardson
    @scott-richardson 2 дня назад

    I have always just assigned a percentage width on each of the flex items and then they shrink and grow nicely.

  • @einatblackrose
    @einatblackrose 2 месяца назад

    That's very helpful. Thank you

  • @AtiqurRahman-gj6mg
    @AtiqurRahman-gj6mg 10 дней назад

    This is really helpful

  • @yogibarista2818
    @yogibarista2818 2 месяца назад

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

  • @atwarwithlife
    @atwarwithlife Месяц назад

    you're the css goat.

  • @tutestheking7838
    @tutestheking7838 2 месяца назад +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 2 месяца назад +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!

  • @ofadiman
    @ofadiman 2 месяца назад +2

    Flexbox is taking control of my life 😳

  • @Lucifer-vz4hg
    @Lucifer-vz4hg 2 месяца назад

    man is saving us

  • @amanuelelhanan4716
    @amanuelelhanan4716 2 месяца назад +1

    This statement opened my eyes Kevin, 4:20

  • @moritzdeiaco2798
    @moritzdeiaco2798 2 месяца назад

    The og border lime hack! Nice video

  • @reneeschke
    @reneeschke 2 месяца назад

    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

  • @OCEMTechZone
    @OCEMTechZone 2 месяца назад +1

    Great Sir 🎉

  • @m12652
    @m12652 2 месяца назад

    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.

  • @percurious
    @percurious 2 месяца назад

    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; ? 🤔

  • @GauravKumar-qe7iu
    @GauravKumar-qe7iu 2 месяца назад

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

  • @tomiekk6255
    @tomiekk6255 2 месяца назад +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?

  • @JoelGallant236
    @JoelGallant236 2 месяца назад +2

    Why not space-between?

  • @GerritforBazeja
    @GerritforBazeja 2 месяца назад

    this is nice to know. Tnx

  • @haidubogdan8712
    @haidubogdan8712 2 месяца назад

    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

  • @ToyotaCharlie
    @ToyotaCharlie 2 месяца назад

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

  • @sonuaryan5287
    @sonuaryan5287 15 дней назад

    Before this video i was controlled by flexbox. Now I'm controlling flex box

  • @djamaatul
    @djamaatul Месяц назад

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

  • @sjd_style
    @sjd_style Месяц назад

    Amazing tnx

  • @MartinDoudoroffLLC
    @MartinDoudoroffLLC 2 месяца назад

    Thanks!

  • @abhim6380
    @abhim6380 2 месяца назад

    Bought the course. Any plans to make grid simplified?

  • @quark2012
    @quark2012 2 месяца назад

    How many times I fight with this problem :) Thanks

  • @Julie-gh5ir
    @Julie-gh5ir 2 месяца назад

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

  • @ClarkSell
    @ClarkSell 2 месяца назад +1

    THAT HOODIE!!!

  • @JimKernix
    @JimKernix 2 месяца назад

    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...

  • @RohitKumar-xs3wh
    @RohitKumar-xs3wh Месяц назад

    nice

  • @rayyanabdulwajid7681
    @rayyanabdulwajid7681 2 месяца назад

    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

  • @MrJettann
    @MrJettann 2 месяца назад +3

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

    • @KevinPowell
      @KevinPowell  2 месяца назад +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.

    • @svnbeats6700
      @svnbeats6700 3 дня назад

      To be honest i use both 😂

  • @vilijanac
    @vilijanac 2 месяца назад

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

  • @user-tl3he1ub7m
    @user-tl3he1ub7m 16 дней назад

    Which browser do you work on ?

  • @sumitsinha995
    @sumitsinha995 2 месяца назад

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

  • @proteus1
    @proteus1 2 месяца назад

    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.

  • @safariknight3239
    @safariknight3239 2 месяца назад

    I swear I only understand this because of Kevin

  • @Techgether
    @Techgether 2 месяца назад

    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 2 месяца назад

      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 2 месяца назад

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

    • @brickslabel
      @brickslabel Месяц назад

      @@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 Месяц назад

      @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

  • @LokiDaFerret
    @LokiDaFerret 2 месяца назад +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 2 месяца назад +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  2 месяца назад +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 😊

  • @srinathsagar4736
    @srinathsagar4736 2 месяца назад

    make a video on
    GRID

  • @RickBeacham
    @RickBeacham 2 месяца назад

    Why did you stop using Firefox? :(

  • @sargaa8471
    @sargaa8471 13 дней назад

    what's happening with the webcam ?

  • @OghamTheBold
    @OghamTheBold Месяц назад

    Lack of understanding hints at hidden algorithm

  • @AlThePal78
    @AlThePal78 2 месяца назад

    almost want to use tables lol

  • @SmileyJack.
    @SmileyJack. 2 месяца назад

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

  • @planesrift
    @planesrift 2 месяца назад

    Just do everything on canvas /s

  • @gE0013
    @gE0013 2 месяца назад +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 2 месяца назад

      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 2 месяца назад

      @@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.

  • @DeepakKumar-ob6ps
    @DeepakKumar-ob6ps 2 месяца назад

    Same price without breakfast? 😂

  • @AJCastello
    @AJCastello 4 дня назад

    Let's go back to tables, seriously.

  • @NoToBusinessCasual
    @NoToBusinessCasual 2 месяца назад +2

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

  • @amanrohilla4435
    @amanrohilla4435 4 дня назад

    Why are you using these thumbnails so frequently 👎

  • @user-ouss
    @user-ouss Месяц назад

    Please don't speak fast

  • @user-ze7nw9ud7m
    @user-ze7nw9ud7m 2 месяца назад

    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 Месяц назад

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