blueprint cssフレームワークを使用して、コンテナの下部/右/中央/中央にテキスト/画像を配置するにはどうすればよいですか?

StackOverflow https://stackoverflow.com/questions/1611161

質問

divコンテナの内容を右または下に揃える簡単な方法はありますか

<div class="span-24 align-right last">Text appears on the right side of the layout</div>

または:

<div class="span-2" id="lots-of-content"></div><div class="span-22 last bottom">Appears at bottom of container</div>

または:

<div class="span-24 vertical-middle last">Middle of the container</div>

「topnav」を配置しようとして作業しているもののサンプルです。以下:

     <div class="container"> 
        <div class="span-16">
            <h1>Header</h1>
        </div>
        <div class="span-8 last vertical-middle">
            <div id="topnav" class="align-right"><input type="button" id="register" class="ui-button ui-state-default ui-corner-all" value="Register" /> or <button type="button" id="signin" class="ui-button ui-state-default ui-corner-all">Sign in</button></div>
        </div>
        <hr />
...
     </div>
役に立ちましたか?

解決

position:absolute を使用します。例:

.align-right {
    position: absolute;
    right: 0;
}
/* Or, alternatively, */
.align-right {
    float: right;
}

.bottom {
    position: absolute;
    bottom: 0;
}
.vertical-middle {
    position: absolute;
    top: 50%;
}

vertical-middle の場合、これはコンテンツ自体ではなく、コンテンツの上端を中央に配置します。

含まれる DIV position:relative であることを確認して、強制的にオフセット親(子の位置が相対的)になるようにします EDIT :つまり、次のルールを追加します。

.container {
    position: relative;
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top