私があなたの質問を正しく理解していれば、あなたは次のものを探しています:
- 中央の列は、画面の中央に固定されています
- 画面のサイズが変更されても、左と右の列は常にそれぞれ左と右に拡張され、残りの利用可能なスペースを埋めます
- 見出しは常にそれぞれの div の中央に配置されます。
OK、最初にいくつかの HTML (これを簡単に理解できるように、プレゼンテーション マークアップを使用しています...プロジェクトに意味的に関連するマークアップを決定する必要があります。
<div id="wrapper">
<div id="left">
<h2>Title Left</h2>
</div>
<div id="center">
<h2>Title Center</h2>
</div>
<div id="right">
<h2>Title Right</h2>
</div>
</div><!-- wrapper -->
少しCSS:
#wrapper {
width: 100%;
overflow: hidden;
}
#left, #right {
background: #FF8C00;
}
h2 {
text-align: center;
}
#center {
width: 500px;
float: left;
background: #e0e0e0;
}
そしていくつかのjQuery:
//document ready function
$(document).ready(function(){
//on page load, call the resizeColumns function
resizeColumns();
//and also call it whenever the window resizes
$(window).resize( resizeColumns );
//we define the function
function resizeColumns(){
//grab the width of the wrapper and save it to a variable
var windowSize = $('#wrapper').width(),
//same thing for the width of the div with id of "center"
centerSize = $('#center').width(),
//windowSize - centerSize = the remaining width of the screen.
//Divide that by 2, and that's how wide each remaining column should be.
//We save that value to a variable
fluidSize = (windowSize-centerSize)/2;
//Now just set the width of the left and right columns equal to fluidSize
//and float them to the left.
$('#left, #right').width(fluidSize).css('float','left');
}
});