DIV (高さが固定されていない) があり、サイトのメニューであるいくつかのフロート画像を常にDIVの下部から一定の距離に配置する必要があります。
コードは次のようになります。
<div class="header" id="header">
<img src="img/aip.png" width="435" height="18" class="pageName"> <!--margin-top: 72px;-->
<!--menu. Last item in line is 1st-->
<img src="img/m-about.png" width="75" height="10"class="menu" >
<img src="img/m-services.png" width="71" height="10" class="menu">
<img src="img/m-portraits.png" width="79" height="10" class="menu">
<img src="img/m-cosplay.png" width="65" height="10" class="menu" >
<img src="img/m-concert.png" width="68" height="10" class="menu" >
</div>
ここで、クラス「メニュー」には「float:right」と表示され、「ヘッダー」DIV の TOP からメニューの位置を設定するマージントップパラメータが含まれます。サイズ変更ごとにJSによる調整を介して、ボトムに関連する固定位置を達成します。これはうまくいきません: DIV を囲む高さは可変 (画面の % で設定) であるため、javascript を呼び出してピクセル値を計算し、margin-top を調整する必要があります。それは厄介な副作用とジャンプを引き起こします。
したがって、代わりに、「ヘッダー」DIV の上部ではなく下部に関連する位置を設定するには、純粋な CSS が必要です。どうすればいいですか?
CSS:
.menu {
float:right;
margin-top:0px; /* adjusted by JS later so menu items have certain margin-top*/
padding:8px;
padding-top:10px;
padding-bottom:10px;
cursor:pointer
}
.header {
display: table-row;
background-color:#181818;
min-height: 114px;
height:10%;
}