Playback starts YouTube’s embedded player (privacy-enhanced mode).
5 Ways to Center with CSS! [VOICE TUTORIAL]
ChannelMarc HintonDescription from the creator
Instagram:
instagram.com/itsmarchinton - @itsmarchinton
Hey! In this video I show you 5 different and equally useful ways to center different types of content with CSS!
Method #1 - 0:30
Written Like:
display: block;
margin: 0 auto;
Description:
This method of centering is by far the one that I use the most. It is a simple, reliable and more of all quick way to center any sort of content, not just text.
Method #2 - 2:05
Written Like:
display: flex;
align-items: center;
justify-content center;
Description:
The flex property is one of the lesser known CSS properties and I think this is down to it being really temperamental. It takes a little practice to get good at but when you do, it's super powerful and you'll use it everyday. It also allows you to center without defining the width of the content.
Method #3 - 3:50
Written Like:
position: absolute;
left: 50%;
transform: translate -50%, 0;
Put the -50%, 0 in brackets. YouTube wouldn't let me.
Description:
This is probably my second or third favourite means of centering with CSS and it seems crazy that it was set up to work this way. By setting the left property to 50% and then using transform to drag the content back by 50% of it's own width, it allows for content to be centered every time. This can be used for more than just text also!
Method #4 - 5:30
Written Like:
Type center in angle brackets and close it off. Anything inside will be centered. YouTube won't let me type angle brackets here.
Description:
I would not recommend this for every piece of content that you need to be centered. It has known compatibility issues with older browsers and website tests will flag this as being outdated. It is good however if you're testing as it's quick, easy to write and remember and to be honest, it works!
Method #5 - 6:45
Written Like:
text-align: center;
Description:
This is pure and simple CSS. This method is limited to just text but it is easy to write and will center your text with just this one parameter!
Website:
www.marchinton.com
Twitter:
www.twitter.com/marchintonn
Facebook:
www.facebook.com/marchintondevelopment
instagram.com/itsmarchinton - @itsmarchinton
Hey! In this video I show you 5 different and equally useful ways to center different types of content with CSS!
Method #1 - 0:30
Written Like:
display: block;
margin: 0 auto;
Description:
This method of centering is by far the one that I use the most. It is a simple, reliable and more of all quick way to center any sort of content, not just text.
Method #2 - 2:05
Written Like:
display: flex;
align-items: center;
justify-content center;
Description:
The flex property is one of the lesser known CSS properties and I think this is down to it being really temperamental. It takes a little practice to get good at but when you do, it's super powerful and you'll use it everyday. It also allows you to center without defining the width of the content.
Method #3 - 3:50
Written Like:
position: absolute;
left: 50%;
transform: translate -50%, 0;
Put the -50%, 0 in brackets. YouTube wouldn't let me.
Description:
This is probably my second or third favourite means of centering with CSS and it seems crazy that it was set up to work this way. By setting the left property to 50% and then using transform to drag the content back by 50% of it's own width, it allows for content to be centered every time. This can be used for more than just text also!
Method #4 - 5:30
Written Like:
Type center in angle brackets and close it off. Anything inside will be centered. YouTube won't let me type angle brackets here.
Description:
I would not recommend this for every piece of content that you need to be centered. It has known compatibility issues with older browsers and website tests will flag this as being outdated. It is good however if you're testing as it's quick, easy to write and remember and to be honest, it works!
Method #5 - 6:45
Written Like:
text-align: center;
Description:
This is pure and simple CSS. This method is limited to just text but it is easy to write and will center your text with just this one parameter!
Website:
www.marchinton.com
Twitter:
www.twitter.com/marchintonn
Facebook:
www.facebook.com/marchintondevelopment
About this tutorial
Marc Hinton published this 8:45 video tutorial on November 4, 2016. It has been watched 37,515 times on YouTube.
- Channel
- Marc Hinton
- Category
- Education
- Duration
- 8:45
- Published
- November 4, 2016
- Views
- 37,515
- Likes
- 564
Tags
Share
This tutorial in other languages
- FR5 façons de Centre avec CSS! [VOIX TUTORIAL]
- ES5 maneras de Centro con CSS! [VOICE Tutorial]
- PT5 maneiras de centro com CSS! [VOZ Tutorial]
- IT5 modi per Centro con i CSS! [VOICE TUTORIAL]
- DE5 Wege zur Mitte mit CSS! [VOICE Tutorial]
- NL5 manieren om Center met CSS! [VOICE TUTORIAL]
- RU5 способов Центра с помощью CSS! [VOICE Учебник]
- PL5 sposobów na centrum z CSS! [GŁOS Tutorial]
- JACSSとセンターへの5つの方法! [VOICEチュートリアル]
- AR5 طرق لمركز مع CSS! [VOICE TUTORIAL]
- HIसीएसएस के साथ केंद्र के लिए 5 तरीके! [VOICE ट्यूटोरियल]
- ID5 Cara untuk Pusat dengan CSS! [VOICE TUTORIAL]