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,391
  • 3
  • 18
  • 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
  • 18,239
  • 30
  • 94
  • 161
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
  • 14,138
  • 5
  • 46
  • 70
0

Try this:

div {
    text-align: center;
}
DrRoach
  • 1,320
  • 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
  • 35,202
  • 5
  • 48
  • 79
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>