Home > Software engineering >  How do I put the text to center of the div?
How do I put the text to center of the div?

Time:12-07

I just made this dropdown, but I have a problem.

When I resize the div/h4, the text goes to the top. I tried fixing this with text-align: center; but it did nothing.

Here's an image of what I'm trying to do:

enter image description here

CodePudding user response:

You can center it vertically and horizontally by doing:

.dropdown-content h4 {
  height: 35px;
  ...
  text-align:center;
  line-height:35px;
}
  • Related