HTML & CSS for Beginners Part 20: How to center a div

HTML & CSS for Beginners Part 20: How to center a div

Kevin Powell

7 лет назад

77,713 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

Dhiren
Dhiren - 11.11.2023 11:32

absolute legend

Ответить
sticksen
sticksen - 08.11.2023 14:51

What are the circumstances where this will not work? I’m usually trying a few centering mechanisms and don’t fully understand why sometimes some work and other times they don’t.

Ответить
Paul Umeh
Paul Umeh - 11.10.2023 15:39

Thank you Kevin❤

Ответить
Rosalie Leclerc
Rosalie Leclerc - 03.10.2023 05:16

thank u vro

Ответить
Aaron Maiden
Aaron Maiden - 31.07.2023 19:15

That's a great great explanation, thank you sir

Ответить
Guestlist +10
Guestlist +10 - 28.05.2023 21:24

thanks!

Ответить
Amdebirhan Abebe
Amdebirhan Abebe - 22.05.2023 11:46

Thank you

Ответить
Jarion Scarlight
Jarion Scarlight - 05.05.2023 10:30

POV: You are an intern

Ответить
Unruly Ronin
Unruly Ronin - 23.04.2023 04:37

Absolutely beautiful. Chef's kiss brother

Ответить
royandescartes
royandescartes - 10.04.2023 01:41

put a div, then set your css to

}width: 800px OR width: 90%
margin-right: auto;
margin-left: auto;
}

done

Ответить
Guilt! Films
Guilt! Films - 23.01.2023 11:17

thank you so much

Ответить
Am!nos ?
Am!nos ? - 07.01.2023 17:52

thanks

Ответить
Moonlight
Moonlight - 30.11.2022 16:35

You're making the CSS a piece of cake for me, thank you Kevin.

Ответить
Mark Zait
Mark Zait - 10.11.2022 15:37

Very interesting video!

Ответить
veer vikram singh
veer vikram singh - 14.09.2022 10:39

why have you take width of 600px

Ответить
Sithum Rajitha
Sithum Rajitha - 05.08.2022 04:13

good job thank you for the lesson

Ответить
Sandile96
Sandile96 - 04.08.2022 17:33

you explained it so well. really appreciate it. thank you Kevin!

Ответить
Handy thehandle
Handy thehandle - 25.07.2022 04:51

Why would you want a max width, though? Some people have really wide screens Why not allow the container to increase to 70% of any screen?

Ответить
Zen 101
Zen 101 - 24.05.2022 23:39

Thank you for being straight and to the point.
And not spending too much time to get to the point.
Many thanks for that.

Ответить
Nathalie Ferreira
Nathalie Ferreira - 25.04.2022 11:43

creating my blog. thank youuu

Ответить
Sars
Sars - 15.04.2022 12:02

Is this still relevant? Are there more ways to achieve the same result

Ответить
Muhammad Zulqarnain
Muhammad Zulqarnain - 01.04.2022 10:44

How to center div exactly at the center of the webpage having space from top, bottom, left, and right sides?
I'm still learning CSS. I use margin to center a div like
.container{
margin-left: 500px;
margin-top: 150px;
}
On desktop it works almost perfectly but on mobile device and iPad, div goes to right and start overflowing and whitespace.
Kindly, tell me how can I center any div professionally?
Thank you for this video.

Ответить
Huhu Haha
Huhu Haha - 24.03.2022 10:25

But sir how to select the right percentage value?

Ответить
Codi Yost
Codi Yost - 06.03.2022 10:35

THIS.

Ответить
Coleman Alexander
Coleman Alexander - 17.02.2022 06:07

I read this title as "How to Center a div: part 20"

Ответить
KUMAR PRATYUSH
KUMAR PRATYUSH - 20.01.2022 08:55

<center></center>

Ответить
Adel bagg
Adel bagg - 10.01.2022 19:17

great explanation as usual, you could add padding to the container so the text inside the div aligns better
thank you

Ответить
Brittany Keith
Brittany Keith - 27.12.2021 15:45

your desktop background belongs on r/restofthefuckingowl. Your tutorials, however, do not.

Ответить
Rahul Jiyani
Rahul Jiyani - 21.12.2021 15:32

Thanks @Kevin Powell , nice video on colors in CSS ,this series is very much helpful .

Ответить
Timotei Satmarean
Timotei Satmarean - 26.11.2021 10:07

This is frustrating because I wraped all code inside body into a div, set its class to container, styled it to margin 0 auto and nothing happens. Same with margin left auto margin right auto…

Ответить
Kraila Mohammed islam
Kraila Mohammed islam - 01.11.2021 20:12

this is it this the good stuff i have been looking for thank you so much.

Ответить
Danny Chang
Danny Chang - 24.10.2021 22:32

great tutorial Kevin!

Ответить
Ash Sargent
Ash Sargent - 29.09.2021 13:34

thank you this helped so much

Ответить
Princino Beats
Princino Beats - 03.09.2021 21:43

good

Ответить
Only God Can Judge Me
Only God Can Judge Me - 03.07.2021 15:30

I went all the way back to your videos because they make me thrilled somehow by their recorders' professionalism

Ответить
Everything Gwenny
Everything Gwenny - 19.06.2021 04:21

Thank you so much for this. So simple yet I couldn't figure this out! It has been driving me crazy for a bit. Now to look for vertical centring

Ответить
malsaso
malsaso - 26.04.2021 00:47

It s an art you re an artist 😎🎓💝

Ответить
Mantralayam Srinath
Mantralayam Srinath - 22.11.2020 02:32

Clear, to the point, no beating around the bush and precise. Excellent. Thank you.

Ответить
Louis Rabeno
Louis Rabeno - 05.11.2020 04:20

Would I be able to set a margin of 10px on the top and bottom but still be able to center a div? If i wrote
margin: 10px auto; would it still be centered on my page with a top and bottom margin of 10px? Thankyou for this video series. Its been very helpful on my journey learning html and css.

Ответить
Hayley K
Hayley K - 12.09.2020 04:07

margin: 0 auto -- now makes SO MUCH MORE SENSE!!! Ty!

Ответить
SohomS
SohomS - 05.07.2020 10:00

I really don't know how to thank you. I am watching every episode and getting new questions and problems when making my own page. AND IN ALL THAT MIRACULOUSLY YOU SOLVE EVERY PROBLEM IN THE NEXT VIDEO. Really really thank you.

Ответить
Phillip Gerba
Phillip Gerba - 27.12.2019 07:14

OK, so I had a problem due to my inattention to detail. When I first tried this everything worked fine... but it somehow overrode my h1 so it was just showing up as regular text. I figured out that when I wrote my first <div class= "container"> I left off that last ">"



I just wanted to put that here in case someone else was having that same problem.

Ответить
Crow Armbrust
Crow Armbrust - 07.12.2019 05:33

awesome!!

Ответить
Muhammed Oğur
Muhammed Oğur - 14.05.2019 17:51

Very nice trick

Ответить
Monty Ksycki
Monty Ksycki - 09.05.2019 07:08

Thank You!!! :)

Ответить
Monty Ksycki
Monty Ksycki - 11.03.2019 08:53

Thank You!! :)

Ответить
Albert Lewis
Albert Lewis - 14.12.2018 09:13

I spent more than a week looking at different videos and reading a couple books just to learn how to center a div and none NONE of them showed this trick. THANK YOU SO MUCH!!!

Ответить
عبد الرحمن ناتسايذ
عبد الرحمن ناتسايذ - 19.07.2018 04:16

thank you very muck

Ответить
Krishna V
Krishna V - 01.04.2018 15:33

Great!!!

Ответить
Salem Majed
Salem Majed - 30.03.2018 10:27

Thanks it's important and very useful.

Ответить