BIG NEWS "How to Center a Div" finally answered (new css property)

แชร์
ฝัง
  • เผยแพร่เมื่อ 18 ต.ค. 2024
  • The align-content: center is now possible for block-level elements too. You no longer need Flexbox or grid to center an element vertically. In this CSS beginner tutorial we are explaining the align-content property in css and how it can be used to center a div vertically. This is now possible for block-level elements as of Chrome 123 has been released.
    👉 Visit our website: www.coding2go.com
    👉 Host your own website: www.hostinger....
    👉 Learn HTML with our Course: www.udemy.com/...
    *Key Topics Covered*:
    New CSS Property: align-content: center;
    How to Center a Div with CSS
    Centering Block-Level Elements
    More information:
    "The CSS align-content property sets the distribution of space between and around content items along a flexbox's cross axis, or a grid or block-level element's block axis."
    CSS MDN Documentation: developer.mozi...
    Read more on Browser Support: caniuse.com/?s...
    👇Here is an overview from the official mdn documentation:
    The align-content property can assume these values:
    align-content: start;
    align-content: center;
    align-content: end;
    align-content: flex-start;
    align-content: flex-end;
    normal
    The items are packed in their default position as if no align-content value was set.
    start
    The items are packed flush to each other against the start edge of the alignment container in the cross axis.
    center
    The items are packed flush to each other in the center of the alignment container along the cross axis.
    end
    The items are packed flush to each other against the end edge of the alignment container in the cross axis.
    flex-start
    The items are packed flush to each other against the edge of the alignment container depending on the flex container's cross-start side. This only applies to flex layout items. For items that are not children of a flex container, this value is treated like start.
    flex-end
    The items are packed flush to each other against the edge of the alignment container depending on the flex container's cross-end side. This only applies to flex layout items. For items that are not children of a flex container, this value is treated like end.
    👆 This section is from the MDN-Documentation: developer.mozi...
    Background Music:
    Track: "Take Off", NEFFEX
    Music provided by slip.stream
    Free Download / Stream: get.slip.strea...
    #CSS #WebDevelopment #HowToCenterADiv CenterDivCSS AlignContentCenter CSS3 WebDesign FrontEndDevelopment CSSHacks WebDesignTips ModernCSS CodingTutorial WebDevTips HTMLandCSS CSSProperty Coding Programming SoftwareDevelopment WebLayout BlockLevelElements

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

  • @kitchentaste8705
    @kitchentaste8705 3 หลายเดือนก่อน +3

    Thanks a lot bro and keep positing

  • @Dorchwoods
    @Dorchwoods 3 หลายเดือนก่อน +7

    In my opinion it would make sense to also allow justify-content on a block element now as well. Text-align seems inaccurate and confusing as a lot of times you might be horizontally centering another div and not just text

    • @zeusek-2137
      @zeusek-2137 3 หลายเดือนก่อน

      Can't wait for fix to that fix!😅

  • @GrafikGerm
    @GrafikGerm 3 หลายเดือนก่อน +2

    It's a really great way. Thanks for sharing the tips

  • @joan-mariacbrooks
    @joan-mariacbrooks 3 หลายเดือนก่อน

    ❤❤❤❤❤❤ CSS coding life just got a little bit easier! Thankyouthankyouthankyou!!!!

  • @kooyaw4445
    @kooyaw4445 3 หลายเดือนก่อน

    Learnt a new thing today. Very informative and helpful

  • @arifhaiman5
    @arifhaiman5 2 หลายเดือนก่อน

    Thanks for sharing

  • @musmanshahid5866
    @musmanshahid5866 3 หลายเดือนก่อน

    Good work keep it up brother

  • @Mr.Unknown0701
    @Mr.Unknown0701 3 หลายเดือนก่อน

    so now we can use the other properties of justify content

  • @Sakinaqi
    @Sakinaqi 3 หลายเดือนก่อน +1

    use center tag

  • @bbsnisso
    @bbsnisso 3 หลายเดือนก่อน

    thank u, that was very helpful

    • @coding2go
      @coding2go  3 หลายเดือนก่อน

      Glad to hear!

    • @bbsnisso
      @bbsnisso 3 หลายเดือนก่อน

      @@coding2go no prob!

  • @loandrisrojas5495
    @loandrisrojas5495 20 วันที่ผ่านมา

    Wait! What about vertical-align

  • @DRAKKAR-95
    @DRAKKAR-95 3 หลายเดือนก่อน

    I really love you ❤ from morocco

  • @theonly.lightfall
    @theonly.lightfall 2 หลายเดือนก่อน

    Jesus. It's such a cool thing!

  • @khorium9626
    @khorium9626 3 หลายเดือนก่อน

    FINALY!

  • @Dj7wiLLY
    @Dj7wiLLY 3 หลายเดือนก่อน +2

    it..doesn't work for me ...
    LE: work's, it was my fault :))) I forgot to set a height to the container so that the element will have the space to be align vertically :D Oups

  • @alexcostal3749
    @alexcostal3749 3 หลายเดือนก่อน

    love it

  • @shoaibmohammad6679
    @shoaibmohammad6679 3 หลายเดือนก่อน

    Awesome

  • @vishalkumarchoudhary8497
    @vishalkumarchoudhary8497 3 หลายเดือนก่อน

    1:14 is really centred any element using just align-content:center

    • @coding2go
      @coding2go  3 หลายเดือนก่อน

      Yes, any block-level element can now be centered vertically using align-content: center; You would also need text-align: center; to center the element's content horizontally. Currently align-content has 79% global browser support on block-level elements, which means that most browser do support this feature, but we still need to wait some time for the devs to implement that in every browser on every device.

  • @MarufHasan-007
    @MarufHasan-007 3 หลายเดือนก่อน

    that was useful

  • @ramlaaal
    @ramlaaal 3 หลายเดือนก่อน

    you are sent by god.

  • @unknownguywholovespizza
    @unknownguywholovespizza 3 หลายเดือนก่อน

    Now we just have to wait for some years to pass so we can use it safely 😁

    • @punithr8661
      @punithr8661 2 หลายเดือนก่อน

      Actually, if you use flex, the containers are by default remains limited to the content (I mean the containers won't take up the whole width/length like a default div.). But this text-align and align content takes up the remaining space of the container too. Am I right ?

  • @shivakumar8263
    @shivakumar8263 3 หลายเดือนก่อน

    Not working😂

  • @nested9301
    @nested9301 3 หลายเดือนก่อน +3

    Css is badly designed from the start what do you mean