将 DIV 与固定宽度左栏的右侧对齐

发布于 2024-09-07 14:23:23 字数 552 浏览 3 评论 0原文

使用流体布局,尝试使用 200px 的左栏和右 div 应该宽度方向扩展。当一些宽内容进入时(比如有几列的表格),如果浏览器不够宽,右侧的 div 会被推到左侧栏下方。

我该如何排序?

#container{
    min-height:300px;
}
#leftBar{
    width:200px;
    float:left;
}
#content{
    float:left;
    padding:20px;
}

<div id="container"> 
 <div id="leftBar"> 
  Left bar here fixed width 200px
 </div> 
 <div id="content"> 
  Should expand to fit parent div, but any long content pushes this beneath the leftBar div
 </div> 
 <div class="clear"></div> 
</div>

With a fluid layout, trying to have a 200px left bar and the right div should expand width wise. When some wide content goes in (say a table with a few columns), if the browser isn't wide enough, the right div gets pushed down below the left bar.

How can I sort this?

#container{
    min-height:300px;
}
#leftBar{
    width:200px;
    float:left;
}
#content{
    float:left;
    padding:20px;
}

<div id="container"> 
 <div id="leftBar"> 
  Left bar here fixed width 200px
 </div> 
 <div id="content"> 
  Should expand to fit parent div, but any long content pushes this beneath the leftBar div
 </div> 
 <div class="clear"></div> 
</div>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文