0

I'm trying to center a time inside a div. I know I am controlling it with inline css. Can do either I suppose.

Basically just trying to align text align in middle of div - vertical-align: middle; - did not work. Image is current look - u can see it is off...

current look

Thoughts?

  <div style="top: 50%; position: relative; font-family: Verdana; font-size: 10pt; color: green; height: 30px; border-top:1px solid ##000;">
  7:45 am
  </div>
Merle_the_Pearl
  • 1,283
  • 3
  • 17
  • 25
  • Try the answer posted here: http://stackoverflow.com/questions/8865458/how-to-align-text-vertically-center-in-div-with-css – chriscoyiez Mar 21 '15 at 14:53

5 Answers5

0

Have you read this thread?

div vertical align middle css

Maybe it will help you :)

Community
  • 1
  • 1
uksz
  • 17,499
  • 30
  • 89
  • 153
0

Try text-align:center

http://jsfiddle.net/Lybfn4ph/

  <div style="top: 50%; position: relative; font-family: Verdana; font-size: 10pt; color: green; height: 30px; border:1px solid black;text-align:center;">
   7:45 am
  </div>
Akshay
  • 13,805
  • 4
  • 42
  • 68
0

Try this:

div {
    text-align: center;
}
DrRoach
  • 1,290
  • 9
  • 16
0

Add line-height style equal to height:

div {
  font-family: Verdana; font-size: 10pt; 
  color: green; 
  height: 60px;
  line-height: 60px;
  border:1px solid #000;
  text-align: center;
  width: 100px;
}
<div>7:45 am</div>
Rick Hitchcock
  • 34,132
  • 4
  • 45
  • 75
0

The best solution will be

<div style="top: 50%; position: relative; font-family: Verdana; font-size: 10pt; color: green; height: 30px; border:1px solid black; text-align:center;">
7:45 am
</div>