2010-12-07 13 views
0

すべてのdivの下部にあるdivを整列しようとしています。divの参照でdivを整列

最後のdivは浮動divで、CSSから上に揃えられます。

画面の解像度を変更することなく、左から揃える方法がわかりません。可能であれば、その位置が常に固定されているdivのIDをcssの助けを借りてそのdivから離しておくことができるかどうか教えてください。

<div id='fixeddiv'>this div is at the top</div> 
<div> rest of the divs </div> 
<div> rest of the divs </div> 
<div> rest of the divs </div> 
<div> rest of the divs </div> 
<div> rest of the divs </div> 
<div> rest of the divs </div> 
<div id='bottom_div'>this div is floating</div> 

おかげ

+0

あなたは私はあなたが私の答え/// – Breezer

+0

をachiveしたいのか理解に苦労をしました。具体的可能性試してくれてありがとう、それはhtmlとcssのためだけだった。 jqueryはありません – kobe

答えて

1

まあ、私が正しくあなたを理解し、あなたはトップに1左の位置合わせを与えたい場合下位のdivと別のdivのdivには、クラスを使用します:

<div id='fixeddiv' class='header-and-footer'>this div is at the top</div> 
<div class='other-content'> rest of the divs </div> 
<div class='other-content'> rest of the divs </div> 
<div class='other-content'> rest of the divs </div> 
<div class='other-content'> rest of the divs </div> 
<div class='other-content'> rest of the divs </div> 
<div class='other-content'> rest of the divs </div> 
<div id='bottom_div' class='header-and-footer'>this div is floating</div> 

CSS:

.header-and-footer { 
    margin-left: 50px; 
} 

.other-content { 
    margin-left: 10px; 
} 

か:

div { 
    margin-left: 10px; 
} 

div.header-and-footer { 
    margin-left: 50px; 
} 
+0

Spiny Normanさん、ありがとうございました。CSSで – dave

+0

が動作しました。div:left:0と宣言しました。それはFirefoxで完全に表示されていますが、画面の左端に表示されています。返信してください。 – dave

+0

あなたの 'div'を含む要素にスタイル' position:relative; 'を追加してください。絶対配置された要素は、その最も近い親に対して相対位置で配置されます。 –

0

ユーザーjqueryのオフセット

http://api.jquery.com/offset/ 

、その後

var offsetval=$('#relativediv').offset() 

$('#bottom_div').css('left',offsetval.left);// change left value the way you want 
+0

を見なかった – dave

関連する問題