0

I have a text-control in Div. I want to place the text aligned vertically centered of div.

The div has following styling:

 display: table-cell;
 vertical-align: middle;
 text-align: Left;
 font-size: 14px;
 height: 80px;
 padding: 0 15px 0 15px;
 overflow: hidden;

Problem:

It aligns text as expected in IE8, but fails in IE7 and IE6.

Anyway to fix it, so it works alright in all IEs.

user1820973
  • 855
  • 2
  • 11
  • 21

3 Answers3

0

use

position:relative top:50% top:-50%

for ie 6/7 , this might be helpful!

dekisha
  • 157
  • 3
  • 11
sourcecode
  • 1,744
  • 2
  • 14
  • 17
0

Add line-height and position to the class

line-height: 80px;
position: absolute;

Finally your CSS looks like:

display: table-cell;
vertical-align: middle;
font-size: 14px;
height: 80px;
padding: 0 15px 0 15px;
overflow: hidden;
border: 1px solid;
line-height: 80px;
position: absolute;

Refer LIVE DEMO

Siva Charan
  • 17,624
  • 9
  • 58
  • 94
0

Try line-height: 80px, I think it will work.

dekisha
  • 157
  • 3
  • 11
  • Doesnot work. Div is supposed to have any number lines possible within specified height. But line-height: 80 shows only one line text. – user1820973 Jan 09 '13 at 11:09