Ajay Yadav
Ajay Yadav

@ATechAjay

14 Tweets 5 reads Jul 24, 2022
10 Different ways to center a div⚑
A Thread πŸ§΅β†“
😍 In this thread, we are going to see the 10 different ways to center a div but before jumping into the thread I like to share the meaning of "align" and "justify" words in CSS.
πŸ“ align = vertical direction
πŸ“ justify = horizontal direction
1️⃣ Grid:
πŸ’‘align-self: It is applied on the grid item/child that is used to control the alignment vertically.
πŸ’‘justify-self: It is also applied to the grid item that controls the alignment to the row axis.
2️⃣ Grid:
πŸ’‘ place-items: It is used to align the elements in horizontal and vertical directions.
3️⃣ Grid:
πŸ’‘ justify-content: It controls the elements in the horizontal direction.
πŸ’‘ align-items: It controls the elements in the vertical direction.
4️⃣ Grid:
πŸ’‘ place-self: It allows you to align an individual item in both the horizontal and vertical directions.
5️⃣ Grid:
πŸ’‘ margin(auto): It automatically aligns the item center of the container.
6️⃣ Flex:
πŸ’‘ align-items: It is used to vertically control items in a container.
πŸ’‘ justify-content: It is used to horizontally control items in a container.
7️⃣ Flex:
πŸ’‘ margin(auto): It automatically aligns the item center of the container.
8️⃣ Flex:
πŸ’‘ justify-content: It is used to horizontally control items in a container.
πŸ’‘ align-self: It is applied on the individual grid item that is used to control the alignment vertically.
9️⃣ Position:
πŸ’‘ inset: It is shorthand for top, right, bottom, and left.
πŸ’‘margin(auto): It automatically aligns the item center of the container.
πŸ”Ÿ Position:
πŸ’‘ Learn it from this thread ↓
πŸ’› Codepen link:
codepen.io
That's all for now, we will meet in the next thread😍
πŸ”” Follow Me @ATechAjay
For:
🌐 Web Development
✨ JavaScript
πŸ“ Writing Skill
πŸ”₯ Motivation
πŸ’Ή Growth
β›” But Not For Only Resources & Shitpost 😁
Thank you so much for staying to the end of this threadπŸ’š

Loading suggestions...