This Should Have Been In CSS Years Ago

แชร์
ฝัง

ความคิดเห็น • 85

  • @fp6260
    @fp6260 วันที่ผ่านมา +116

    We got "align-content: center;" before GTA6.

    • @DevDiveIn
      @DevDiveIn  วันที่ผ่านมา +10

      lol. Should be a metric on MDN and caniuse. Before GTA6: yes.

    • @NotJayUU
      @NotJayUU วันที่ผ่านมา

      we got "align-content: center;" before GTAV.......

  • @diego.almeida
    @diego.almeida 7 วันที่ผ่านมา +105

    This works as long as the child element is not a container element with a defined width, such as div or section. Because the text-align property doesn't work on div itself, only on the content.

    • @gerooq
      @gerooq 7 วันที่ผ่านมา +2

      does the text-align property apply to the content of the inner container elements too? like recursively?

    • @thecoolnewsguy
      @thecoolnewsguy 7 วันที่ผ่านมา +3

      ​@@gerooqyes

    • @gerooq
      @gerooq 7 วันที่ผ่านมา +1

      @@thecoolnewsguy well that sucks, unless it's overridable

    • @macavalli2619
      @macavalli2619 3 วันที่ผ่านมา

      Brooootthhheeerrrrr 😵‍💫🤌

    • @StiekemeHenk
      @StiekemeHenk 3 วันที่ผ่านมา +4

      ​@@gerooq The word you are looking for is cascade

  • @OfficialViper
    @OfficialViper วันที่ผ่านมา +1

    Straight to the point, no bullshit. Subscribed.

  • @perfectionbox
    @perfectionbox วันที่ผ่านมา +3

    Someday we'll treat HTML and JS as a dress rehearsal, and take everything we now know and develop a vastly better replacement which will run alongside them in every browser, and after enough sites migrate, we drop the old languages.
    And throw a huge party.

  • @Voltra_
    @Voltra_ 4 วันที่ผ่านมา +24

    Not cool to kill a meme Chrome!

  • @albumin30days90
    @albumin30days90 2 วันที่ผ่านมา +5

    "HOW TO CENTER A DIV"

  • @Vendavalez
    @Vendavalez 2 วันที่ผ่านมา +6

    Oh god… thankfully my brain has forgotten the arcane magic one had to do 10+ years ago to try to center something on a web-page…

    • @NotJayUU
      @NotJayUU วันที่ผ่านมา

      this property came out out over 10 years ago.... so you could just use this

    • @Vendavalez
      @Vendavalez วันที่ผ่านมา

      @@NotJayUU and how many browsers actually supported it, as opposed to just claiming that they did?
      To be fair, I wouldn’t know. This is more of a me problem, but at the time I needed to support websites that were being accessed in South America where you could only assume that they would have the version of the browser that came with whatever OS they were running.
      That’s what I was trying to communicate with the “+” but I get that is really not clear at all.

    • @NotJayUU
      @NotJayUU วันที่ผ่านมา

      @@Vendavalez there's a website caniuse, it's good for checking this stuff.
      2015 was when it was supported in all major browsers

    • @jerichaux9219
      @jerichaux9219 21 ชั่วโมงที่ผ่านมา

      Now you may begin to heal.

  • @AerysBat
    @AerysBat 2 วันที่ผ่านมา +4

    There is a new multikeyword display property. display: block flex or display: inline flex will let you specify both the placement and the inner layout. (Why these two distinct features were ever mashed together in one property is beyond me)

  • @vahekhachaturian2424
    @vahekhachaturian2424 3 วันที่ผ่านมา +9

    i still can't believe that this is a thing

  • @perfectionbox
    @perfectionbox 3 วันที่ผ่านมา +49

    This is why html needs a revamp

    • @cake3014
      @cake3014 3 วันที่ผ่านมา +10

      Yeah, but the problem with revamping html is older browser support. I never get why there's so much importance on supporting old browsers, especially now that Windows 7 has been discontinued and Windows 10 is going soon too. So the majority will be updated to many recent browsers. But it's a matter of making a website accessible to everyone. We have plenty of frameworks now too. And I know the React peeps won't get over their ex if and when html gets a major revamp. It also depends a lot on bigger corporations that decide on a standard for the web.

    • @Endrit719
      @Endrit719 3 วันที่ผ่านมา +6

      @@cake3014 people still use windows xp, trust me

    • @snesmocha
      @snesmocha 2 วันที่ผ่านมา

      @@Endrit719then just create a legacy mode that will replace the code with legacy compatible or something, most sites aren’t even compatible with old browsers

    • @giovannibandinelli9792
      @giovannibandinelli9792 2 วันที่ผ่านมา

      ​@@Endrit719 I know that that is the case but I don't get why 😮‍💨😮‍💨😮‍💨

    • @Maleficarum999
      @Maleficarum999 2 วันที่ผ่านมา

      @@cake3014 Not everyone cares about new technology and companies want to deliver websites to maximum amount of people, general population not being tech savvy enough isn't a good argument to abandon backwards compatibility. Yes you can revamp HTML which will work thousand times better than old HTML but try selling a fact that it will only work for 50% of users to any client and get ready to be laughed at.

  • @realdragon
    @realdragon 17 ชั่วโมงที่ผ่านมา

    Me who knows nothing about CSS: This is truly a game changer

  • @Flyde
    @Flyde 2 วันที่ผ่านมา +3

    This is awesome! Thanks for sharing

    • @guyincognito5663
      @guyincognito5663 2 วันที่ผ่านมา

      Yeah, web design is “awesome”.

  • @rhiji4583
    @rhiji4583 2 วันที่ผ่านมา +13

    so Safari might support this 2034

  • @ya64
    @ya64 6 ชั่วโมงที่ผ่านมา

    And it only took... *checks calendar*... 27 years!

  • @YoKKJoni
    @YoKKJoni 2 วันที่ผ่านมา +5

    the beauty of css is that prob none of these will work for my purpose XD

    • @theseangle
      @theseangle 12 ชั่วโมงที่ผ่านมา

      So what's your purpose

  • @wil-fri
    @wil-fri วันที่ผ่านมา +1

    Me: create a row with a column inside. Center that column. Put something in that column. Center the content of that column, voila volare vio

  • @iub.9893
    @iub.9893 2 วันที่ผ่านมา

    Perfect

  • @tediumluvs
    @tediumluvs 4 วันที่ผ่านมา +1

    Finally.

  • @totoshampoin
    @totoshampoin 7 วันที่ผ่านมา +5

    YESSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSs

  • @yerenzter
    @yerenzter 4 วันที่ผ่านมา +9

    I've already used this since 2019

    • @NotJayUU
      @NotJayUU วันที่ผ่านมา

      ya... this came out in 2012, I don't get why every is acting like this is something crazy...

    • @codyrap95
      @codyrap95 วันที่ผ่านมา

      Because if I understood correctly it's not using grid or flex. It works directly on block elements

    • @theseangle
      @theseangle 12 ชั่วโมงที่ผ่านมา

      It was only released on March 19th 2024.
      It works on display: block.
      What you were using only worked with display: flex or grid.
      The support now is only about 79% align-content on display block, unlike the 96% align-content on display flex

    • @theseangle
      @theseangle 12 ชั่วโมงที่ผ่านมา

      ​@@NotJayUU why are y'all acting like some kind of OGs while knowing nothing about the topic

    • @NotJayUU
      @NotJayUU 8 ชั่วโมงที่ผ่านมา

      @@theseangle ?

  • @Rovsau
    @Rovsau 2 วันที่ผ่านมา

    Question: Is there a way today to make a set of divisions behave like a table, where it would dynamically adjust the size of each row and column?

    • @DevDiveIn
      @DevDiveIn  2 วันที่ผ่านมา +1

      That you can. Using the display property. You more or less mimic the structure of a table with divs. And apply the appropriate display property. e.g. = display: table; = display: table-row; ... etc. I wouldn't recommend it though. It's a lot easier just to use a table. There is a lot of accessibility goodness when you use the semantically correct HTML tags. If it isn't actually a table, I would look into using display grid.

    • @Rovsau
      @Rovsau 2 วันที่ผ่านมา

      @@DevDiveIn That's very good to hear! Thank you.
      The problem with using Tables, at least 15 yrs ago when I was active, was how Web Crawlers interpret them. Tables are expected to contain tabular data, and not contextual content.
      Do you know if Accessibility tools like Screen Readers will be able to handle websites designed with tables today?

    • @DevDiveIn
      @DevDiveIn  2 วันที่ผ่านมา +1

      @Rovsau - Ya I don't miss those table days, or IE 6 for that matter ;) If the content belongs in a table, then screen readers prefer you use the html tag. When you use a divs by default screen readers lose reference to what other divs belong in the same row/col. You have to do some work to reimplement that functionality so screen readers can read it properly. If you're laying out an entire site. I wouldn't use tables or the div equivalent, there are much better alternatives now. Screen readers would try and read your site as a table which it is not. display: grid does pretty much the same thing as tables (and more), and is much more robust and flexible. I have a video on it if that helps.
      th-cam.com/video/B6QddhvpUUo/w-d-xo.html

  • @NotJayUU
    @NotJayUU วันที่ผ่านมา +1

    it's strange you titled the video: "this should have been in CSS years ago".... considering the spec for align-content was released in 2012, and supposed by every browser by 2015
    I guess the newness if it's supported in a block layout, but like.... before that is was just 1 additional property "display: flex/grid"....

    • @DevDiveIn
      @DevDiveIn  วันที่ผ่านมา +1

      Yep exactly. We should have been able to vertically center things with block elements years ago. I guess having so many alternatives really slowed progress on having it implemented for block elements.

  • @cariyaputta
    @cariyaputta 2 วันที่ผ่านมา +2

    Failed so many interviews because of this lol

  • @nustaniel
    @nustaniel วันที่ผ่านมา

    My goto is position: absolute; inset: 0; margin: auto; width: fit-content; height: fit-content.

  • @zvala396
    @zvala396 วันที่ผ่านมา +1

    This only works with pictures of cats.

  • @etherweb6796
    @etherweb6796 3 วันที่ผ่านมา +2

    You could also use width 100% height 100% and object-fit also (assuming no other content in div)

  • @squarshyy
    @squarshyy วันที่ผ่านมา

    What happens when the container has two children? Would it behave the same as flex or grid? Or else?

    • @DevDiveIn
      @DevDiveIn  วันที่ผ่านมา

      From what I tried it looks to be the same as flex. The only difference I noticed was how margins collapse. Flex stacks margins on top one another, block merges the top and bottom margins together.

  • @AnweshAdhikari
    @AnweshAdhikari 21 ชั่วโมงที่ผ่านมา

  • @dustsucker4704
    @dustsucker4704 10 ชั่วโมงที่ผ่านมา

    Works but I feel like we didn't need another way of doing it. As grid and flex Cover 99.9% of usecases im not aware of elements that have to be Block that have content i dont See the usecase for this.

  • @HemitPatel-s3f
    @HemitPatel-s3f 19 ชั่วโมงที่ผ่านมา

    dream come true lmao

  • @jayjaayjaaay94
    @jayjaayjaaay94 3 วันที่ผ่านมา +1

    Why I see this cat picture everywhere?

  • @haiffy
    @haiffy 5 ชั่วโมงที่ผ่านมา

    Still prefer flex items-center justify-center

  • @nomadshiba
    @nomadshiba วันที่ผ่านมา +1

    1:10 thats not correct
    place-items: center;
    means:
    justify-items: center;
    align-items: center;
    there is also place-content: center;
    which means
    justify-content: center;
    align-content: center;
    content is the area of the grid or flex layout where the child item lives in
    and item is the actual item in that area

    • @DevDiveIn
      @DevDiveIn  วันที่ผ่านมา +1

      @nomadshiba - good call out. That is my bad. I misspoke.

  • @CEOstar
    @CEOstar 19 นาทีที่ผ่านมา

    hallelujah

  • @Fido1hn
    @Fido1hn 2 วันที่ผ่านมา +1

    Why would text-align work on an image. Wierd, it literally says 'text'

    •  2 วันที่ผ่านมา

      Because image is by default an inline element. It is easier to imagine the image as just another big character in the text.

  • @beaticulous
    @beaticulous วันที่ผ่านมา

    Why not content-align?

    • @ytchannel6569
      @ytchannel6569 วันที่ผ่านมา +1

      why not con-align-tent?

    • @mahmoudzakria6946
      @mahmoudzakria6946 20 ชั่วโมงที่ผ่านมา

      Like this's the real problem!?

  • @collapsingspace
    @collapsingspace 4 วันที่ผ่านมา +2

    place-items is actually shorthand for justify-items and align-items

  • @syedmuhammadhasnain5054
    @syedmuhammadhasnain5054 7 วันที่ผ่านมา

    Vs code theme name

    • @DevDiveIn
      @DevDiveIn  7 วันที่ผ่านมา +3

      Dark Modern. But, I created a profile where I customized the colors.
      Created a Gist of my settings.json for my profile.
      gist.github.com/dev-divein/bdad2f449811b6d191cab520730dee74

    • @richochet
      @richochet 3 วันที่ผ่านมา +1

      ​​@@DevDiveInNice, thanks!

  • @gregoromogus2033
    @gregoromogus2033 7 วันที่ผ่านมา +1

    BRAHHGHAHAHA

  • @HemitPatel-s3f
    @HemitPatel-s3f 19 ชั่วโมงที่ผ่านมา

    dream come true lmao