Paolo Rossi
Paolo Rossi

Reputation: 2510

CSS vertical-align middle a inline-block

I decided to use the inline-block for my layout, but I have problems to place a block in the vertical middle position (pan2)

<div id="container">
<div class="row">
    <div class="pan1">
        <div class="content">
          LEFT PANEL 
          <br /><br />
          <br /><br />
          <br /><br />
         </div>
    </div><div class="pan2">
        <div class="content">
           RIGHT PANEL <br/>
        </div>
    </div>
</div>
</div>

CSS

body { 
font-family: Arial, Helvetica, sans-serif; 
font-size: 12px; 
background-color: #f5f6f7; 
} 

#container { 
width: 600px; 
margin-left: auto; 
margin-right: auto;
background: #ccc;
} 

.row { 
margin-top: 10px; 
background: #fff; 
padding: 0px;
border: 1px solid #000;
} 

.pan1  { 
width: 300px;
display: inline-block;
vertical-align: top;
*zoom: 1;
*display: inline;
padding: 0px;
border: 1ps solid #000;
background: #999;
} 

.pan2  { 
width: 200px;
display: inline-block;
vertical-align: middle;
*zoom: 1;
*display: inline;
padding: 0px;
background: #ccc;
} 

.content {
padding: 0px;
border: 1px solid #000;
font-size: 12px;
}

I tried to set vertical-align: middle in pan2 block but this remains at the top. How could I make using the display inline-block? thanks

DEMO

Upvotes: 0

Views: 176

Answers (2)

CervEd
CervEd

Reputation: 4243

The vertical-align property works on the baseline, which is established by the first element and thus affects elements that follow.

Check out this post on CSS-tricks for a nice run-down http://css-tricks.com/almanac/properties/v/vertical-align/

Upvotes: 0

DaniP
DaniP

Reputation: 38252

Change vertical-align for pan1:

.pan1 {
   vertical-align:middle;
}

DEMO

Upvotes: 2

Related Questions