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.

BFry
  • 905
  • 2
  • 11
  • 24

3 Answers3

0

use

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

for ie 6/7 , this might be helpful!

dekisha
  • 177
  • 3
  • 12
sourcecode
  • 1,802
  • 2
  • 15
  • 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,940
  • 9
  • 60
  • 95
  • This doesnot work when my text has line breaks. It doesnot show the text in line breaks. – BFry Jan 09 '13 at 11:09
0

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

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