0

I've got what I think to be quite an interesting problem. Whenever I try to vertical-align all the elements I need - it won't work, but if I leave one out, it appears to work. Here's the code:

<body style='margin:0; width:100%; height:100%; background-color:#e8e7e7'>
  <div id='holder' style='width:100%; height:100%; margin:0'>
    <div id='blackout' style='width:100%; height:100%; background-color:#000; opacity:0.5; position:absolute; z-index:1'></div>
    <div id='data_holder' style='width:100%; height:100%; z-index:2; position:relative; text-align:center'>
      <div id='geo' style='width:96.9%; height:40%; background-color:#9F6; display:inline-block; vertical-align:middle'></div>
      <div id='dis_v' style='width:24%; height:25%; background-color:#9F6; display:inline-block; vertical-align:middle'></div>
      <div id='dis_d' style='width:24%; height:25%; background-color:#9F6; display:inline-block; '></div>
      <div id='dis_b' style='width:24%; height:25%; background-color:#9F6; display:inline-block; vertical-align:middle'></div>
      <div id='dis_o' style='width:24%; height:25%; background-color:#9F6; display:inline-block; vertical-align:middle'></div>
    </div>  
  </div>
</body>

I would like to know what's causing this problem and how can I solve it and vertical-align all the elements inside the data holder div.

Here's a jsFiddle of the problem.

Sidetik
  • 610
  • 2
  • 9
  • 16

2 Answers2

0

vertical-align work just for text. I usually use margin/padding for vertical align. And add your code to a playground.

faerin
  • 1,915
  • 17
  • 31
AleshaOleg
  • 2,171
  • 1
  • 15
  • 29
0

I think the key idea that you're missing is that you need to set line-height in data_holder. That's just how vertical-align works. (You'll need to use a height like 200px rather than 100%.) See this question for better info:

How do I vertically center text with CSS?

Community
  • 1
  • 1
mdahlman
  • 9,204
  • 4
  • 44
  • 72