Stop Using Pixels/Rems/Percentages To Define Widths In CSS

Sdílet
Vložit
  • čas přidán 29. 06. 2024
  • 🌎 Find Me Here:
    My Blog: blog.webdevsimplified.com
    My Courses: courses.webdevsimplified.com
    Patreon: / webdevsimplified
    Twitter: / devsimplified
    Discord: / discord
    GitHub: github.com/WebDevSimplified
    CodePen: codepen.io/WebDevSimplified
    #Shorts

Komentáře • 216

  • @jordancutler7552
    @jordancutler7552 Před 2 lety +1004

    Kyle nice short but comon man the title was really clickbaity. Theres no way you are actually recommending to stop using pixels / rem / % for width.

    • @forkerion
      @forkerion Před 2 lety +36

      I think he meant you should stop using that for exact size.

    • @Al_Gonzo
      @Al_Gonzo Před 2 lety +133

      It is clickbaity, this is what CZcams has become. Dont hate the player, hate the game.

    • @RodrigoDAgostino
      @RodrigoDAgostino Před 2 lety +42

      @@Al_Gonzo who makes what the game is if not the players? :S

    • @Al_Gonzo
      @Al_Gonzo Před 2 lety +17

      @@RodrigoDAgostino the admins? Heads of youtube?

    • @RodrigoDAgostino
      @RodrigoDAgostino Před 2 lety +48

      @@Al_Gonzo do admins or heads of YT put a gun to every youtuber’s head and force them to abide by the click-baity guidelines? Yeah, I didn’t think so

  • @dagonzalez1757
    @dagonzalez1757 Před 2 lety +341

    Liked the content, disliked the title

    • @ibrahimal4342
      @ibrahimal4342 Před 2 lety +29

      Sad clickbait title. Views over informative titles from an educational channel 🤦‍♂️

    • @BNewtonUK
      @BNewtonUK Před 2 lety

      Money && Views > Quality of Information

    • @sdehh
      @sdehh Před 2 lety +1

      @@ibrahimal4342 without this title maybe you would have never seen this video, so its content

  • @jlee3361
    @jlee3361 Před 2 lety +40

    designer gives you a layout.
    kyle: theres no way i can do this anymore

  • @Elijah_Lopez
    @Elijah_Lopez Před 2 lety +103

    Better title: Define widths easily with fit-content

    • @At1ksh
      @At1ksh Před 9 měsíci

      Well then u would never click to watch the full short if he did that

  • @aaronwaterman3888
    @aaronwaterman3888 Před 2 lety +16

    Wow! I stopped using pixels, rem and percentages and now none of my websites scale properly!

  • @ujirooduokpe8243
    @ujirooduokpe8243 Před 2 lety +74

    The problem with fit-content, max-content, min-content or auto is that if you want to do animations or transitions on the width or height, it doesn't work.

    • @dziugazz
      @dziugazz Před 2 lety +5

      calc(max-content - 100px) ?

    • @CottidaeSEA
      @CottidaeSEA Před 2 lety +5

      @@dziugazz Using pixels with calculations is pretty bad, as you don't have any context for what the content width is.
      calc works though, so I'll give you that.

    • @guillermodanielmazzarigiov1768
      @guillermodanielmazzarigiov1768 Před 2 lety +4

      @@dziugazz I think it would be better to use calc(max-content - 10%) imo since you don't know the exact size of all screens were you'll website will be displayed

    • @cedrictheveneau9141
      @cedrictheveneau9141 Před 9 měsíci

      @@CottidaeSEAI agree with the pixels part but doesn’t CSS know the exact width all the time ? We don’t if we don’t inspect it but pretty sure CSS does calculations, no ?

    • @CottidaeSEA
      @CottidaeSEA Před 9 měsíci

      @@cedrictheveneau9141 width: 100% depends on parent. If parent has no width, your calculation will be off. Unless things have changed recently, using max-content in calc is not possible either.

  • @MuhammadAdamFirdaus
    @MuhammadAdamFirdaus Před 2 lety +37

    I like most of your videos because simplicity, straight to the point. But this title of video make me feel intimidated. Kyle, please don’t like the other CZcamsrs who tend to not using existing features and you should do this instead.
    You just introducing another feature, but it doesn’t mean we need to stop using px, rem, %, etc.

    • @peter-jb
      @peter-jb Před 2 lety +1

      gonna cry?

    • @moldman5694
      @moldman5694 Před 8 měsíci

      @@peter-jb gonna piss your pants maybe?

  • @wally-the-web-dev5142
    @wally-the-web-dev5142 Před 2 lety +43

    Found that while this is a crazy cool feature it often does not work on IOS devices and safari - still waiting for the browser to unify under one banner… would make front end dev so much easier lol

    • @andyl9920
      @andyl9920 Před 5 měsíci

      Agreed. I'm struggling with building responsive websites. Media queries are tedious and way too much work.

  • @badunius_code
    @badunius_code Před 2 lety +19

    So another "Sthap using X" bs
    I need some child of wrap flex container to take all of its width
    Which one would it be? Auto? Max?
    Or maybe, just maybe, a 100%?
    What if I need children of a flex container to take equal parts disregarding their content?
    What if I need a fixed table layout?

    • @ChaoticNeutralMatt
      @ChaoticNeutralMatt Před 2 lety

      Bad title

    • @badunius_code
      @badunius_code Před 2 lety +1

      @@ChaoticNeutralMatt of course it is. Because when someone is searching for helpful information, rarely they google for "how to stop using percentages in CSS"

    • @cedrictheveneau9141
      @cedrictheveneau9141 Před 9 měsíci

      For the last point, I’d suggest grid
      Don’t forget that your tag is in display block by default and uses all the available space…
      Theoretically you should never have to set a width by yourself as if you use the proper display type everything should be automatically defined
      Though it takes some time to get the hang of it, I’ll give it a shot at some point to see if it’s actually doable in an actual project

  • @beinyourguard
    @beinyourguard Před 2 lety

    really enjoying these shorts series. straight to the point and really useful

  • @stasbazylevych9981
    @stasbazylevych9981 Před 2 lety +1

    Also very useful minmax() function. You can set minimum width when content is small and max when it is large.

  • @TheBumbleCheese
    @TheBumbleCheese Před 2 lety +55

    Can you do a video about deploying a MERN App or Hosting in general? Would be awesome. Maybe about AWS.

    • @TheBumbleCheese
      @TheBumbleCheese Před 2 lety +1

      @@mr.darkheart2979 At least nothing helpful or something straight forward. There are some videos about hosting but either they are talking like 50 minutes around the point without explaining the essentials or they present a third party platform which runs the app over their own domain.

    • @mrs8683
      @mrs8683 Před 2 lety

      @@mr.darkheart2979 Vercel, and Heroku are pretty good 👍🏽

  • @rafaelalejandrodiazcruz4438

    I NEEDED a short like this!!

  • @osraneslipy
    @osraneslipy Před 4 měsíci

    Awesome video. I had been lost in this feature for an incredibly long time. And you explained it perfectly in seconds.🙏

  • @MohsinExperiments
    @MohsinExperiments Před 2 lety

    Keep making these CSS short videos because they are really useful.

  • @crim-son
    @crim-son Před 2 lety

    Awesome content Kyle... Loving the Shorts

  • @AICameron
    @AICameron Před 2 lety

    Really appreciate your content Dev! Always delivered clearly and calmly. Great work my man, please keep this up! 🤝

  • @flethacker
    @flethacker Před 2 lety +10

    i love that guitar intro. it has literally conditioned me to remember all the teachings on this channel and alert my brain for more. You should throw that in prior to these tiny short form videos

  • @sashaikevich
    @sashaikevich Před 2 lety +1

    Nice! I want more of these lesser known css rules

  • @CottidaeSEA
    @CottidaeSEA Před 2 lety +3

    I honestly need more examples of when these things would actually be useful, because one of the only cases where I find it useful is for text.

  • @rhym8882
    @rhym8882 Před 2 lety +17

    finally straight to the point content

  • @MohammadMalan
    @MohammadMalan Před 2 lety

    PS I really love these shorts that you are making . . . Thank you.

  • @theworldismine7788
    @theworldismine7788 Před rokem +4

    Summary:
    The best is fit and you should use it

  • @hiteshsuthar1097
    @hiteshsuthar1097 Před rokem

    Thanks, you cleared it all in just one short 👍

  • @king_bobby_the_I
    @king_bobby_the_I Před 9 měsíci +1

    Great short and all, but the video never explained the title. Could probably change it into something like "Cool CSS Scaling Features"

  • @Gamingworld-17
    @Gamingworld-17 Před 2 lety

    I wanted to lean just some few things in java script but it just so important that I must know it if I really want to be a dev, I wish you post a video on java script full course I will appreciate that am a big fan of your, I watch almost every single video of your I have seen thus far, since mid 2020

  • @heckyes
    @heckyes Před 2 lety

    I wasn't sure about your channel when I first subbed. Really glad I did though.
    I'm a back end dev who only ever does CSS when I can't bribe someone else to do it for me lol.
    Your videos have been really helpful. I keep putting off learning CSS from scratch cause it's so huge now.

    • @gourabpaul3560
      @gourabpaul3560 Před 2 lety

      his hairstyle gives it away, tbh he is one of the best webdev teacher on yt

  • @CreativeTutorialsWeb
    @CreativeTutorialsWeb Před 2 lety +2

    Thanks so much Kyle love the work you put into making videos every one of your videos are a blessing 💙 you too are a blessing 😁

  • @user-bi2so9dr3t
    @user-bi2so9dr3t Před 9 měsíci

    very well explained, thanks!

  • @busyrand
    @busyrand Před 2 lety

    Thanks for breaking down these new CSS properties.

  • @kemal_ozturk
    @kemal_ozturk Před 2 lety +3

    Loving these shorts, super helpful information 😁

  • @billy8461
    @billy8461 Před 9 měsíci

    fit content is amazing! i use it to center absolute divs all the time

  • @lyndonmilligan9398
    @lyndonmilligan9398 Před 2 lety

    Thank you, Kyle!! I didn't know what min, max, fit-content is before untill watched this video

  • @sanjeevKumar-eg6hp
    @sanjeevKumar-eg6hp Před 2 lety

    This is will be very useful if your doing responsive design or adding footer

  • @2k18banvalaki5
    @2k18banvalaki5 Před 2 lety

    I want to understand all of the spacing and ordering of CSS but Idk where to find the best short guides. This video is less than 1 minute and explained a bunch of things regarding content sizes

  • @CrazyCodingChannel
    @CrazyCodingChannel Před 2 lety +1

    You explain it very cool

  • @julie4055_
    @julie4055_ Před 2 lety

    I like using media queries, it might seem tedious to manually define a rem value for each screen size but then everything can look just as you want it to look.

  • @vicsystems
    @vicsystems Před 2 lety

    Thanks for this

  • @zeinab_3107
    @zeinab_3107 Před 2 lety

    You're amazing Kyle😍😍🙏🏽🙏🏽🙏🏽

  • @kitcat2449
    @kitcat2449 Před 7 měsíci

    Useful example, thankie

  • @noblesse3092
    @noblesse3092 Před rokem

    Title is kinda misleading but I must admit the content is actually solving a problem I hD

  • @manankataria
    @manankataria Před 2 lety

    Thank you for this 🙂

  • @erikplachta
    @erikplachta Před 2 lety

    Appreciate the content, here. Thank you.

  • @JoeX92
    @JoeX92 Před 2 lety

    Thanks! I always asked myself what was the difference!

  • @nicolasmayorga8288
    @nicolasmayorga8288 Před rokem

    Amazing thanks ❤

  • @daniedmola7465
    @daniedmola7465 Před 2 lety

    Wow, thanks so much for this

  • @thiago670
    @thiago670 Před 2 lety

    I'm not a front-end developer, but I really like to watch his channel videos.

  • @rezarahman1782
    @rezarahman1782 Před 2 lety +2

    What about image? For example in a portfolio website about section where there is some text and image side by side, it’s very difficult to adjust both column.

  • @lovenangelo5415
    @lovenangelo5415 Před 2 lety

    Really helpful

  • @blenderpanzi
    @blenderpanzi Před 8 měsíci

    Cool, didn't know these! Though caniuse says it's still -moz-fit-content for Firefox.

  • @BNewtonUK
    @BNewtonUK Před 2 lety +6

    *PLEASE* stop using click bait titles to recommend stupid things to people learning to code.
    Telling up and coming coders that they should completely get rid of certain skills and code from their toolbox is so irresponsible of you.
    Please, instead, encourage learners to understand the “use case” and pros and cons of each.
    Absolutely no aspect of coding should be completely disregarded unless the code spec itself deprecates or excludes it.

  • @viniciusm.m.7822
    @viniciusm.m.7822 Před 2 lety +2

    Dont know why, but i always need to check if the video speed is ok o.O

  • @tresvecesno7071
    @tresvecesno7071 Před 5 měsíci

    Thanks!

  • @ZelenoJabko
    @ZelenoJabko Před 2 lety

    Never needed this. Display block and inline-block covers everything I wanted to do

  • @hyperprotagonist
    @hyperprotagonist Před 2 lety +1

    You’re telling me that your entire CSS doesn’t contain a single percentage, rem or pixel? Hard to believe.

  • @adrianbrewster8213
    @adrianbrewster8213 Před 2 lety +1

    I am enjoying these concise vids. You really make the topics simplified. Thank you.

  • @harshitjoshi3082
    @harshitjoshi3082 Před 2 lety

    Thanks 👍

  • @aram5642
    @aram5642 Před 2 lety

    For the reaspn shown by max-content they could have provided a :clipped selector

  • @samuelmatheson9655
    @samuelmatheson9655 Před 2 lety +1

    I'LL NEVER GIVE UP MY REMS

  • @patahgaming
    @patahgaming Před 10 měsíci

    Thanks now i know what i have to use

  • @RubberDuckCoding
    @RubberDuckCoding Před 2 lety

    VERY NICE!

  • @MdNaimurRahmanHera
    @MdNaimurRahmanHera Před 2 lety

    Such a nice video. ❤️🇧🇩

  • @seahmadnailal-darabi8985
    @seahmadnailal-darabi8985 Před 4 měsíci

    good job

  • @DanieleManca1983
    @DanieleManca1983 Před 8 měsíci

    Click-baity or not, it is an interesting perspective to take into account.

  • @samdelamarter4557
    @samdelamarter4557 Před 2 lety

    Is there a way to use this in a table so each column is as wide as it’s widest cell?

  • @jonathanandersson5723
    @jonathanandersson5723 Před 7 měsíci

    Hey its the DOOM on potatoes guy!!

  • @JasonJA88
    @JasonJA88 Před 2 lety

    Font size based on parent container that's what I want in CSS but for now we have to use JavaScript

    • @alexg4927
      @alexg4927 Před rokem

      What about em units? They are relative to the parent container font size

  • @iang9675
    @iang9675 Před 2 lety

    Is it possible to size a parent / sibling element based on the size of a nested child element? I’m implementing a custom drop down menu using ul, li, div, button, and would like the min width of the button that opens the dropdown to be the width of the largest li child.

  • @mridulsetia4974
    @mridulsetia4974 Před 2 lety

    How do we make that resizable text box ?

  • @vuongqtvn
    @vuongqtvn Před 2 lety

    Very nice

  • @TimHoekstra
    @TimHoekstra Před 9 měsíci

    Any idea how to size a font so that the text always fits on N lines of content?

  • @colmenasio5542
    @colmenasio5542 Před 6 měsíci

    bro being handsome af

  • @core36
    @core36 Před 2 lety +1

    But does it work in internet explorer 4?

  • @guanghuili474
    @guanghuili474 Před rokem

    how you resize the container with mouse?

  • @adarshkhatri993
    @adarshkhatri993 Před rokem

    How does he made resizable container??

  • @wtiy
    @wtiy Před 2 lety

    how do u control the size of the container?

  • @DarsoMAN
    @DarsoMAN Před 9 měsíci

    Fantastic

  • @CurtisUpshall
    @CurtisUpshall Před 2 lety

    Is this property well-supported? Last I checked it doesn't work in all contexts

  • @dia5
    @dia5 Před 2 lety +3

    You didn't answer the question why we should stop using px/rem/%. You just explained us how the *-content works, that's it.

  • @josephlivengood4508
    @josephlivengood4508 Před 2 lety

    Can this be used inside a grid div?

  • @WillievanZyl
    @WillievanZyl Před 2 lety

    Whats the difference between fit and auto?

  • @azulay7
    @azulay7 Před 2 lety

    The big Q is how to use it with text-overfow: ellipsis?

  • @seobookpro
    @seobookpro Před 5 měsíci

    Is the auto work on all browsers
    I think there was updates last year that may be fixed it on full

  • @Winner12349
    @Winner12349 Před 2 lety

    Love ♥️and Respect from India 🇮🇳

  • @cool__name
    @cool__name Před 2 lety +2

    Differences between auto and fit-content?

    • @mikopiko
      @mikopiko Před 2 lety

      auto takes up all the space while fit-content takes up what's needed I guess.

  • @sripranav
    @sripranav Před 2 lety

    Then what's the difference between fit and auto?

  • @annaatitech5908
    @annaatitech5908 Před 2 lety

    I don't think that's gonna end, I'm more of a percentage, I don't it sucks but fixed sized pixels are worst as I think

  • @thomasjoli-coeur6037
    @thomasjoli-coeur6037 Před 2 lety

    Vw units for the win IMO

  • @codewithsheikh2805
    @codewithsheikh2805 Před 2 lety

    Problem with this is it's not supported in all browsers or atleast only new versions support it

  • @MCChubbyUnicorn
    @MCChubbyUnicorn Před 2 lety

    Some websites are so bad that they use the max content while not allowing phone users to scroll to the right making the text mostly unreadable. Garbage design sometimes.

  • @avi12
    @avi12 Před 2 lety

    The only downside of these values is if your company requires you to support IE11

  • @victory_lucky
    @victory_lucky Před 2 lety

    how about browser compatibility?

  • @alvaroprietovideos
    @alvaroprietovideos Před 2 lety

    mmmm... so, inline-block elements are fit-content by default?

  • @krishnachaitanya8095
    @krishnachaitanya8095 Před 6 měsíci

    How he is moving divs with with mouse

  • @timnelson3431
    @timnelson3431 Před 8 měsíci

    What's the difference between AUTO and FIT content?

  • @Azmeroth1370
    @Azmeroth1370 Před 5 měsíci

    auto doesn’t work for my canvas for some reason

  • @mohamadmohamad4242
    @mohamadmohamad4242 Před 2 lety

    nice video but can you tell me how are you resizing the div?

  • @MarteDesignGrahicStudio

    Thanks bro. This helps a lot

  • @linkonplays
    @linkonplays Před 2 lety

    Usefull

  • @agpproductions4224
    @agpproductions4224 Před 2 lety

    I love you