box-sizing: border-box explained

Поділитися
Вставка
  • Опубліковано 31 січ 2025

КОМЕНТАРІ • 260

  • @WebDevSimplified
    @WebDevSimplified 5 років тому +513

    This is by far the best CSS property. I remember when I first discovered this I felt like I unlocked CSS God powers, and now I cannot imagine writing any CSS without it.

    • @IhsanMujdeci
      @IhsanMujdeci 5 років тому +16

      This plus flexbox

    • @ne9835
      @ne9835 5 років тому +1

      @@IhsanMujdeci What about CSS Grid?

    • @IhsanMujdeci
      @IhsanMujdeci 5 років тому +1

      @@ne9835 I sadly under utilize that property. Do you like it?

    • @ne9835
      @ne9835 5 років тому +2

      @@IhsanMujdeci Property? CSS Grid isn't a property or are you talking about box sizing?

    • @komkwam
      @komkwam 5 років тому +1

      @@ne9835 CSS grid is quite new compare to flexbox and therefor it has less browser support.

  • @patatasfritasviewer
    @patatasfritasviewer 4 роки тому +70

    How to resolve 2 years of CSS frustration. That should be the first property learnt in any CSS lesson

  • @sjn_
    @sjn_ 5 років тому +19

    Coincidentally, I was thinking about searching around for its purpose yesterday while trying to sleep and this video appeared this morning lol. Thanks for posting this, Kevin. You are very helpful.

  • @chiefplankton8307
    @chiefplankton8307 3 роки тому +16

    Hey Kev!
    I am new to web dev and have been taking up the Odin Project for some time now. It' has been challenging to learn all these new concepts from various resources. I read all these things theoretically, understand it a little bit and then I finally come to your videos which makes it SO MUCH BETTER. I get to really understand the concept in suchha subtle way! Defo joining your patreon once I get a job on this path! :) Kudos to you, I hope you're doing good.

    • @capp1306
      @capp1306 2 роки тому

      How has been you progress so far? I Just started CSS on the Odin Project.

    • @chiefplankton8307
      @chiefplankton8307 2 роки тому

      @@capp1306 I finished the foundations and did 25% on the intermediate and then paused it because I wanted to learn front-end first so I switched to react. Now I got an internship at a local company for the backend on Laravel. Odin Project foundations really helped me develop the HTML, CSS, JS skills required to do the basic frontend part of web-portals. It was comparatively easy for me to learn Bootstrap/Tailwind next on advancing on commercial CSS. Well, focus on the course and build things for yourself every week.
      If you run into any problem ask and search alot. I know you didn't ask for advice but I did it anyway haha. Anyways, if you need help and stuff regarding the course or anything around it you can get me at ergasiamellow@gmail.com. Goodluck :)

    • @zaid4708
      @zaid4708 2 роки тому

      @@capp1306 im 6 months in, currently doing todo list project, if you have time, do study webpack 5 if you want to early on if you're choosing fullstack JavaScript, since that's one of the most frustrating topic you'll come across in fullstack JavaScript, but anyways odin project is pretty good, i feel confident with my skills

    • @capp1306
      @capp1306 2 роки тому

      Is that a practice project? My main goal is security. My plan is to learn just front-end to make money, if I like full-stack I'll try But not now

  • @pancakemaxita
    @pancakemaxita 5 років тому +64

    better explained than forums and courses! Thank you. You saved my time!

  • @nataliadi9
    @nataliadi9 2 роки тому +6

    I'm not sure I would have kept learning CSS if not your explanations that make things so much easier. Thank you for the videos, Kevin!

  • @alexdoe6524
    @alexdoe6524 Рік тому +1

    I had trouble understanding this while reading a lesson about it so I came here and now I'm good. Thanks again for your videos, they are the best!

  • @jackmeister9482
    @jackmeister9482 Рік тому

    Man, there are tons of channels out there for Web development topics, you are by far THE BEST! Keep going Kevin.

  • @salakosunday
    @salakosunday Рік тому

    This is most concise video tutorial from kelvin that he did not rant. No wonder Bing search of all, suggest this to me. great one. keep it up.

  • @fahanyc3638
    @fahanyc3638 5 років тому +5

    Thanks, Kevin. You have a very pleasant voice and you explain things well! Two thumbs up!

  • @sum_itt20
    @sum_itt20 3 роки тому

    So far, the best explanation of this concept... I got the required visualization. Thank u for showing your mercy on us.

  • @secure_the_bags620
    @secure_the_bags620 4 роки тому

    Dude thank you so much. This 5 min video made more sense to me than hours and hours of reading about border-box.I just couldn't understand it for the longest time until now!

  • @start-media
    @start-media 3 роки тому

    This is by far the best (visual) explanation for box-sizing.

  • @lazzawhite4746
    @lazzawhite4746 4 роки тому

    I have watched about 5 videos trying to understand this concept and I got it right away with your video. Thanks so much.

  • @damianduran5427
    @damianduran5427 2 роки тому +1

    THANK YOU so much, I saw that property in a lot of vídeos but I never tried it bc i thought I'm never gonna use it but now I see how useful it is, thanks so much!

  • @34GL3H34D
    @34GL3H34D Рік тому

    been watching your videos for no reason. Cause love the way you explaining. Cheers!

  • @josegarboza3825
    @josegarboza3825 4 роки тому +1

    Thank you so much for this video...this is one of those CSS things I never really got around to learning and you were able to explain it masterfully in 5 min. Kudos to you sir.

  • @awhitechilliify
    @awhitechilliify 4 роки тому

    Omg thank you, after watching few videos I came across this one and the penny has finally dropped, thank you so much, your visual example was the best one I saw!

  • @siriusgd4753
    @siriusgd4753 5 років тому +1

    Truely helpful Kevin! I had a situation where I was changing attributes on a box and wasn't understanding why they weren't doing what I expected. Now I know. You are definitely worth the Patreon account. (Edited: For spelling)

  • @noodlespwn42
    @noodlespwn42 3 роки тому

    I watched this video with 'Call Me' by 90sFlav in the background and it was such a treat. Thanks for the content!!

  • @TheCocoaDaddy
    @TheCocoaDaddy 3 роки тому

    Awesome! I had never seen the 'box-sizing' property until I started seeing your tutorials. So, this explanation helps a lot! Thanks for posting!

  • @programmingplug9536
    @programmingplug9536 3 роки тому

    You're the true king of CSS, thanks a lot!

  • @martinmohammed4087
    @martinmohammed4087 2 роки тому +2

    Basically with the default value of box-sizing: (content-box) the box will be expanded across the viewport if padding or border is included. Because those components/ parts will take part in the total width/height of the box.
    With box-sizing: border-box the total width/height of the box equals the specified width and height. Border and padding are not included in the total width but they reduce the inner width/height of the content. As a result the padding/border look like now they are reversed into the element (text looks shifted).

  • @denhamk
    @denhamk Рік тому

    Thank you! Didn’t realize I had to set the universal selector to box sizing as well.. I only put it in my body and html and was wondering why my divs were still expanding!! Phew.
    Thanks, Kevin

  • @alexgochenour8740
    @alexgochenour8740 8 місяців тому

    So very useful, and so concisely presented. Thank you Kevin

  • @mariodlp
    @mariodlp 2 роки тому

    Thanks. Honestly I was feeling like an idiot for not understanding this concept but making a very visible demonstration of this solved it for me.

  • @rebelmachine88
    @rebelmachine88 5 років тому +2

    I feel like a great weight has been lifted off my shoulders, thank you Kevin!

  • @javieru5871
    @javieru5871 2 роки тому

    Your voice and intonation is so ASMR.

  • @MP-mh1tu
    @MP-mh1tu 4 роки тому

    Best explanation I've seen so far

  • @m.smanoj4688
    @m.smanoj4688 2 роки тому

    east or west kevin powell is the best for css
    box sizing actually confuses a lot visited many websites but this video helped me alot.

  • @BimaAgungSaputra-gt4px
    @BimaAgungSaputra-gt4px Рік тому

    This is literally the cure of all my problem with css right now holy sh*t

  • @Dawid-lb8fe
    @Dawid-lb8fe 4 роки тому

    It has actually changed my life today. Thank you for the explanation :)

  • @MuhammadSaid01
    @MuhammadSaid01 4 роки тому

    Oh my god, I was looking for this explanation I was facing a design problem for many days now its sovled ! thank you so much

  • @smrutiranjan4444
    @smrutiranjan4444 Рік тому

    finally found one video where i totally clear my doubt . THANK YOU SIR

  • @TheCodeDealer
    @TheCodeDealer 5 років тому +1

    Thanks for explaining this in a much more understandable way

  • @justinlinn1810
    @justinlinn1810 5 років тому +25

    Have been web dev for two years and feel betrayed no one has informed me of this trade secret

  • @busyrand
    @busyrand 5 років тому +1

    Fantastic explanation of one of my favorite lines of code. I like the advanced practice of adding it to pseudo-elements. Never thought or heard of that practice before. The part about incorporating other code where the rule was different was nice too. I recently ran into this. Very neat presentation.

  • @ralexand56
    @ralexand56 5 років тому +1

    Thank you, thank you, thank you! This has been driving me nuts when it came to designing full view layouts because those nasty scrollbars would pop up out of nowhere.

  • @crstfrdrnt
    @crstfrdrnt 4 роки тому

    you cleared the doubts codecademy planted in me in 2 minutes! you're awesome!

  • @adarshpandey2978
    @adarshpandey2978 5 років тому

    You are really good on picking up topics to discuss. Really helpful discussion. Thanks a lot❤️❤️❤️

  • @siriusgd4753
    @siriusgd4753 5 років тому +1

    btw... I love your video cover photos... This one with you scratching your temple looking confused... LOL!!!

  • @mariopizzaro
    @mariopizzaro 2 роки тому

    Thanks Kevin, happy to follow your video's, learn a lot !

  • @samhatake
    @samhatake 3 роки тому

    That one bit about inherit . Super genius

  • @hannah51238
    @hannah51238 2 роки тому

    This has actually just solved a problem I was having with a layout. Thank you sir!

  • @asmahamdym
    @asmahamdym 8 місяців тому

    I use to hate CSS until I found your channel!

  • @HostDotPromo
    @HostDotPromo 5 років тому +3

    Border box is a game changer for sure 👍

  • @esagecantu
    @esagecantu 11 місяців тому

    Simple and straightforward explanation. Thank you.

  • @x3zlo
    @x3zlo 2 роки тому

    Great explanation in a short video! Thanks so much Kevin :D

  • @louisgamor
    @louisgamor 4 роки тому

    This is awesome Kev.👍 I've always been wondering why you say it makes our lives much easier

  • @rick5522
    @rick5522 Рік тому

    Kevin, you are awesome!

  • @yutthanayahan7784
    @yutthanayahan7784 5 років тому

    love to see your new video, thank for sharing.

  • @SumanRoy.official
    @SumanRoy.official 5 років тому +3

    Thanks for this one, I always wondered what it was, often confused.

  • @rekan_98
    @rekan_98 3 роки тому

    I was having no idea about the box now I got to understand thanks a lot.

  • @briankk8
    @briankk8 4 роки тому

    Thanks Kevin Powell for the awesome tutorial

  • @DianaTan
    @DianaTan 4 роки тому

    Thanks for the information. Learning CSS.

  • @chlouis-girardot
    @chlouis-girardot 5 років тому +1

    Always clear and helpful. Thanks a lot Kevin!

  • @TheImaginativeSachin
    @TheImaginativeSachin 2 роки тому

    This was very enlighting . Thanks Kevin

  • @DragonRoyZ
    @DragonRoyZ 2 роки тому

    Thank you. This is simple and easy to understand.

  • @beec3694
    @beec3694 5 років тому +1

    Thank you for another great tip Kevin!

  • @owlthetyto
    @owlthetyto Рік тому

    Absolutely on point. Awesome.

  • @erykkryszewski5803
    @erykkryszewski5803 5 років тому +1

    Man I beg you... Please create a tutorial about scroll efects on websites. There is nowhere good explanation of all this. Im talking about showing some objects only when we scroll to this section, any other animations that more and more websites use nowadays. It gives our static website a bit of power and interaction that makes the user feel that this is so professional :) or some kind of scrolling only between sections - when we scroll only once on mouse it still gives us another section etc (we dont have to do it manually). Please keep upvoting this post to allow Kevin see it, maybe he will help us! :) Greatings!

    • @KevinPowell
      @KevinPowell  5 років тому +1

      I see 99% of comments (some will slip through for sure), no need to upvote :) - I've got something sort of planned for this already, but it might be awhile.

    • @erykkryszewski5803
      @erykkryszewski5803 5 років тому

      @@KevinPowell thank you. if i were you i would put a bit more functionality into your movies, to make it useful on real websites. waiting for another projects, greatings!

  • @Platinum989
    @Platinum989 3 роки тому

    This video was such a help. When I am able to I am going to buy some shirts!

  • @oleksiipetrenko3824
    @oleksiipetrenko3824 3 роки тому

    Great explanation, thank you, Kevin

  • @nawendusingh2858
    @nawendusingh2858 5 років тому

    best explanation on youtube.

  • @anuj7286
    @anuj7286 5 років тому +1

    Thanks i was waiting for this video 👍

  • @lawrenlelko
    @lawrenlelko 5 років тому

    Top shelf, as usual!

  • @eminm6383
    @eminm6383 3 роки тому

    one of the most useful info in 5 mins :D

  • @sumitsharma6738
    @sumitsharma6738 3 роки тому

    Box sizing border box NOW CLEAR.... Thanks!!!!

  • @baabla
    @baabla 5 років тому +1

    Was looking for this. Thank you!
    Also, make a video regarding footer. How to place it at the bottom of the page when there is not enough content covering the whole viewport height between the navbar and footer.

    • @crousdioll
      @crousdioll 5 років тому +1

      you can use position

    • @baabla
      @baabla 5 років тому

      @@crousdioll I've tried position fixed which obviously scrolls with the page. I have tried position absolute, but then it doesn't stick below the content. Giving a min-height of 100% to body also didn't seem to help.

    • @crousdioll
      @crousdioll 5 років тому +1

      @@baabla okay see this: stackoverflow.com/questions/39794712/how-to-make-footer-go-to-bottom-when-there-isnt-enough-content-on-page

    • @baabla
      @baabla 5 років тому +1

      @@crousdioll alright will check it out. Thanks!

  • @alulapetros6048
    @alulapetros6048 4 роки тому

    Best Explanation Ever !

  • @MauriceLacerda0
    @MauriceLacerda0 5 років тому +1

    The box-sizing: inherit is a nice trick!

    • @sammas533
      @sammas533 4 роки тому +1

      Really, I don't understand. I mean, in the universal selector (*) when you write "box-sizing: border-box", any "box-sizing: content-box" you write after will overwrite the "box-sizing: border-box" of the universal selector (*). That's why I don't understand why to use the inherit trick. Maybe I'm wrong. Can you explain me pls?

    • @jimhalpert9803
      @jimhalpert9803 3 роки тому

      @@sammas533 because what if you have 10 divs under a container? Instead of giving all those 10 divs content-box , one could simply give their parent container the box-sizing: content-box and all those divs will inherit it. Easily reduce redundancy.

  • @shubhamkohli7719
    @shubhamkohli7719 4 роки тому +1

    Really helpful tutorial

  • @MrMinutmen1
    @MrMinutmen1 Рік тому

    you teach very well, thank you so much.

  • @HowTo-nr7uk
    @HowTo-nr7uk 5 років тому

    Thank you kevin for short and simple explanation.
    subscribed and liked :-)

  • @nelsonR
    @nelsonR 5 років тому +1

    Precise explanation, thank you!

  • @charlesmullen8024
    @charlesmullen8024 5 років тому

    border box saved my life

  • @sourabhkulkarni1731
    @sourabhkulkarni1731 4 роки тому

    Thank you Kevin.

  • @suleman234
    @suleman234 2 роки тому

    this was very usefull ! thank you so much kevin

  • @Krenil.
    @Krenil. 3 роки тому +1

    really helpful thanks for this amazing tutorial. 🔥

  • @Saf9838
    @Saf9838 4 роки тому

    Finally! Thank you!

  • @mertefe4345
    @mertefe4345 2 роки тому

    thank you Kevin.

  • @Ken-ke9bi
    @Ken-ke9bi 3 роки тому

    Thanks, this was very helpful!

  • @zenithkokkodan7037
    @zenithkokkodan7037 4 роки тому

    U make amazing video. very much simplified

  • @__jake.m
    @__jake.m 3 роки тому

    Thank you so much! You explained it so well.

  • @yaqubuabdulmalik2869
    @yaqubuabdulmalik2869 4 роки тому

    Very good explanation

  • @sagormajomder
    @sagormajomder 2 роки тому

    Thank you so much. great explanation

  • @GigMyRig
    @GigMyRig 3 роки тому +2

    Outstanding, clear and concise explanation ✨ Thank you, Kevin.

  • @rapararapapa7623
    @rapararapapa7623 3 роки тому

    Hi Kevin could you make a video on the overflow Property?

  • @atarixle
    @atarixle 5 років тому +1

    helped me to remove a "calc" statement, thanks!

  • @adamfirdaustan6415
    @adamfirdaustan6415 2 роки тому

    Thank you for this!!

  • @revvnijaa4177
    @revvnijaa4177 3 роки тому

    Thanks much u r my css guru love from india

  • @_us.m.an_
    @_us.m.an_ 3 роки тому

    You made it look easy.

  • @fabrizioalpuche5984
    @fabrizioalpuche5984 3 роки тому

    Gracias, nice and clear explanation

  • @babylikescoffee
    @babylikescoffee 4 роки тому

    Thanks for this!

  • @SparklesBohanson
    @SparklesBohanson 5 років тому

    Thanks Kevin

  • @Ksenseisei
    @Ksenseisei 4 роки тому +1

    min 3:05 I didnt quite understand what you mean with the pseudo elements, could you explain please? I actually dont understand the whole action of the like *, *:: .... I know what they mean on their own but not quite what they do together like * ::before {box-sizing...}

  • @Kirsehirli40able
    @Kirsehirli40able 5 років тому

    Wow, thank you very much for this explanation!

  • @totitotojatiwijayanto521
    @totitotojatiwijayanto521 3 роки тому

    love it. it's helpful my project

  • @aat5968
    @aat5968 4 роки тому

    Well explained !

  • @SadanandPamadi
    @SadanandPamadi 5 років тому

    Very nice explained sir. Loved it