DEV Community

Robson Muniz
Robson Muniz

Posted on

8 3

🔥3 Ways to Center Content Horizontally and Vertically in CSS✨

3 Ways to Center Content Horizontally and Vertically in CSS✨

Image description


Classic Option

.classic{
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%,-50%);
}
Enter fullscreen mode Exit fullscreen mode

CSS Grid Way

.grid{
    display: grid;
    place-items: center;
}
Enter fullscreen mode Exit fullscreen mode

Flexbox Way

.flexbox{
    display: flex;
    align-items: center;
    justify-content: center;
}
Enter fullscreen mode Exit fullscreen mode

đź›´ Follow me on:
https://bit.ly/3oBQbc0


Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

đź‘‹ Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay