Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I vertical center a label in a div?

Tags:

I have a div with a height of 30px.

I want to add plain text to this div. How can I make the plain text appear on the center of my div? i.e, the text will be shown 15px under the top of the div.

I tried a label with margin-top: 15; but it didn't work.

like image 822
hubert Avatar asked Nov 03 '09 12:11

hubert


2 Answers

height: 30px; line-height: 30px; padding: 0; 
like image 59
Björn Avatar answered Sep 22 '22 06:09

Björn


Following CSS would work

text-align:center; vertical-align:middle;  display:table-cell; 
like image 42
Ketan Khairnar Avatar answered Sep 20 '22 06:09

Ketan Khairnar