css - 如何让子 div 在 HTML 中填充其父 div 的所有剩余水平空间?

标签 css html

test http://o7.no/U5w2EV

它的结构是:

<div id='container'>
    <div id='play'>▶</div>
    <div id='res'>RES</div>
    <div id='bar'>test</div>
    <div id='time'>0</div>
</div>

样式是:

对于#container

 #container
{backgroundColor:'#CCCCCC',
position:'absolute',
bottom:'-40px',
width:'100%',
height:'40px'}

对于按钮 #res 和 #bar

#res , #bar
 {width:30px; 
 height:30px; 
 border:1px solid #DDDDDD; 
 margin:5px; 
 font-weight:bold; 
 cursor:pointer; 
 float:left}

#time

#time
 {float:'left',fontSize:'16px',margin:'12px 5px'}

注意:容器的宽度(取100%的地方)是动态变化的。

如何将 CSS 设置为 #bar div 填充其他 div 剩余的所有空间?

最佳答案

您上面发布的代码不完整。它的格式也不正确 (css)。

但我“认为”如果你删除内部 <div> 上的 css float的,而是让它们成为 display: inline-block;你应该能够声明 CSS width:内部百分比<div>的并让它们装满您的容器。

关于css - 如何让子 div 在 HTML 中填充其父 div 的所有剩余水平空间?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12549449/

相关文章:

html - Bootstrap container 或者 Well keep the well one size and enlarge text

html - 如何仅在 CSS 中存储 "state"?

javascript - 简单的前端 Controller 导致 php 中的 css 和 javascript 损坏

css - ExtJs 4 Firefox css 条件

html - IE9 渲染问题 - 空白条(水平线)

javascript - CSS:添加文本溢出属性后,绝对定位的文本不会在 div 中居中

javascript - 隐藏/显示与 jquery 无法正常工作

CSS 问题 : What has precendence?

html - 如何对齐 HTML 表格中的两个组件?

javascript - 形状未出现在 html Canvas 上