質問

CSS Gurusがそこにあるため、最初のラベル/セレクトペアを中央揃えになるCSSを把握できませんが、2番目のものは中央に揃っています。

以下の図の問題を見てください。私の目標は、最初のラベル/セレクトペアを中央に整列させ、それを実現させるCSSルールを理解することです。

画像の記述ここで

<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>
.

これはあなたがこれを行動で見ることができる場所です... fiddle

役に立ちましたか?

解決

これを行う簡単な方法は、label要素にドロップダウンセレクタの高さの線の高さに等しい線の高さを与えることです。ただし、このソリューションは、マルチラインではないラベルがあり、上記のvertical-alignメソッドを使用する必要がある場合は、テキストの単一行だけではありません。

label {
    line-height:25px;
}
.

jsfiddle

他のヒント

label, select {
    display: inline-block;
    vertical-align: middle;
}
.

You have additional divs around the first label/select pair, which force this behaviour.

If you remove the unnecessary divs around the first label/select pair and add the same class as in the second, you should be fine

<div class="pure">
    <form class="pure-form-inline">
        <div class="pure-control-group">
            <label>Choose Project:</label>
            <select></select>
        </div>
        <div class="pure-control-group">
            <label>Choose Customer:</label>
            <select></select>
        </div>
    </form>
</div>

Modified JSFiddle

Try with this vertical align fix:

/* Vertical Align Fix */

.valign:before {
    content:"";
    height:100%;
    display:inline-block;
    vertical-align:middle;
}
.valign > * {
    display: inline-block;

}
.valign-m { vertical-align: middle; }

Give the class (.valign) to the parent (The div containing the select)

And this other class to the inner elements (select + label)

See if it works.

.pure .pure-u {
    line-height:25px;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top