これまでのところ、コードのスニペットはかなりうまく機能していますが、解決する必要がある小さな不具合があります。
目標は、2 つの項目を隣り合わせに配置することです。1 つは固定幅で、もう 1 つは指定されたコンテナー内の残りの使用可能な幅を埋めます。
流動的なアイテムは適切にサイズ変更されていますが、ブラウザ/コンテナのサイズが変更されるたびに少し問題が発生します。
参照: http://jsfiddle.net/tedgrafx/kTeCC/
2 つのアイテムはフローティング状態ですが、幅のサイズを変更すると、特定の幅でそれらがフローティングせず、垂直方向に積み重なって表示され、一方が他方の下に押し出されます。
この小さな不具合を修正して、サイズ変更中にシームレスに見えるようにするにはどうすればよいでしょうか?
あらゆる/すべての助けをいただければ幸いです。
HTML:
<div class="panel">
<div class="left">Left</div>
<div class="right">Right</div>
</div>
CSS:
html, body{
margin:0;
padding:0;
}
.panel {
float:left;
width:100%;
margin:0;
padding:0;
}
.left {
float:left;
width:50px;
height:10px;
margin:0;
background:red;
}
.right {
float:right;
width:100%;
height:10px;
margin:0;
background:blue;
}
Javascript:
// Resize Top-Right Panel section on the Entity Panels.
$(document).ready(function () {
resizeRight();
$(window).resize(function () {
resizeRight();
});
});
function resizeRight() {
// Subtract the width of the TopLeft section from the width of the entityPanel div:
var right_width = $('.panel').width() - ($('.left').width());
// Set the width of the TopRight to an even number:
if (right_width % 2 == 0) { // Using the modulus operator to determine if 'mid_width' even number.
right_width = right_width + 1; // Now we set 'mid_width' to an odd number.
// Set the width of the TopRight section:
$('.right').css({ 'width': right_width });
}
}