DEV Community

Discussion on: Rarely known CSS Tips

Collapse
 
aleksandrhovhannisyan profile image
Aleksandr Hovhannisyan

To vertically center contents of div
If one line of text set ๐—น๐—ถ๐—ป๐—ฒ-๐—ต๐—ฒ๐—ถ๐—ด๐—ต๐˜ to height of container. If non-text contents wrap the DIV in a ๐—ฑ๐—ถ๐˜€๐—ฝ๐—น๐—ฎ๐˜†: ๐˜๐—ฎ๐—ฏ๐—น๐—ฒ DIV & set inner DIV to ๐—ฑ๐—ถ๐˜€๐—ฝ๐—น๐—ฎ๐˜†: ๐˜๐—ฎ๐—ฏ๐—น๐—ฒ-๐—ฐ๐—ฒ๐—น๐—น

This is outdated. Just use flexbox or CSS grid. Don't use table formatting.

Collapse
 
dhanushnehru profile image
Dhanush N

Yes you are right. This can be useful to beginners who are in the process of learning the css properties before they get into flex box or css grid

Collapse
 
codedgar profile image
codedgar

I always use

.elm{
display:flex;
align-items:center;
justify-content:center;
}
Enter fullscreen mode Exit fullscreen mode
Collapse
 
sirajulm profile image
Sirajul Muneer

place-items: center
Voila!