javascript - 如何让一个占用剩余空间的并排 Div?

标签 javascript jquery html css

我的问题是我想要一组并排的 div。这些 div 可以增长到任意高度,因此垂直对齐很重要。正如另一篇 SO 帖子所建议的那样,为了解决垂直对齐问题,我有一个类似于此的结构。请帮我填空。

<div id="main-container">
   <div class="formatter">
       <div class="content1">
              <!--- I am fixed at 200px ---->            
       </div>  
   </div>
   <div class="formatter">
       <div class="content2">
              <!--- I have a rendered element.  I don't know exactly how high or wide I am, but I'm not going to take up the whole thing. --->
       </div>
   </div>
   <div class="formatter">
       <div class="content3">
              <!--- I have some text and just want to take up the rest of the main container less padding and borders ----->
       </div>
   </div>
</div>

在浏览器中显示:

Table display

CSS:

#main-container {
     width: 900px;
}

.formatter {
     display: inline-block;
     vertical-align: middle;
}

.content1 { 
     float: left;
     width: 200px;
}

最佳答案

您需要将它们声明为table-cell

关于javascript - 如何让一个占用剩余空间的并排 Div?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24717852/

相关文章:

html - 如何使用 CSS 为所有浏览器垂直居中 div 元素?

html - 具有自定义 css 的输入类型范围 - 拇指在 IE 中显示不正确

javascript - 使用 nvd3 库显示单系列多条形图

javascript - Turbolinks 总是像往常一样加载页面

javascript - Angular Material Flex 给出了错误的尺寸

jquery - 将全屏图库导航更改为项目符号导航

javascript - 防止对 PHP 的虚假循环 ajax 请求

javascript - 过度使用 jquery

javascript - 使用 AJAX 加载内容后音频无法播放

javascript - HTML "File"/打开文件对话框解决方法