How to align label and select box vertically (middle)

John Livermore picture John Livermore · Jun 4, 2014 · Viewed 21.9k times · Source

For the CSS gurus out there, I cannot figure out the css that makes the first label/select pair not middle align, but the second one does align in the middle.

See the problem in the image below. My goal is to make the first label/select pair align in the middle and to understand the css rules that make it happen.

enter image description here

<div class="pure">
    <form class="pure-form-inline">
        <div class="pure-g">
            <div class="pure-u labelArea">
                <label>Choose Project:</label>
            </div>
            <div class="pure-u-1-4">
                <select></select>
            </div>
        </div>
        <div class="pure-control-group">
            <label>Choose Customer:</label>
            <select></select>
        </div>
    </form>
</div>

Here is where you can see this in action...Fiddle

Answer

aaronburrows picture aaronburrows · Jun 4, 2014
label, select {
    display: inline-block;
    vertical-align: middle;
}