I would like to know what ways exist to align a div vertically, or any attribute such as section or article. I know that the question is very general but I just recently started with CSS. Thanks.
I would like to know what ways exist to align a div vertically, or any attribute such as section or article. I know that the question is very general but I just recently started with CSS. Thanks.
There are thousands of ways:
Line-height method
Example: Vertically aligned text.
Result:
The CSS Table method
Example:
Result:
Absolute Positioning and Stretching
Example:
Result:
Floating Div (Floater Div)
Example:
Result:
I got the examples from this link . There are several more.
You can use the pseudo-elements :before + vertical-align:middle
there are two very easy methods
you can use flex
Here I leave you 2 options, which are the ones I use:
The second option is the best in my point of view, although it already has an answer it may be useful to you.