Center div text vertically in its background

Here, the text is on the top side of its background. How do I vertically center the text?

To vertically center text in a div container, you can assign a class to the container and insert this into your CSS file:

    text-align: center;

It only aligns horizontally

Oops, didn’t see that.

You can insert margin: auto inside the class.

1 Like

If you want it always in the center:

#div {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);

I solved my own question. What I meant was something like this:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.