更新:--这是目前为止最接近解决方案的一种解决方案:http://jsfiddle.net/bfcr62yd/11/
我在解决以下问题时遇到了困难。简而言之,我需要一个元素来填充剩余的宽度,其中所有其他元素都是水平叠加的,都有固定的宽度。
UI有5个包装器元素,需要用固定的最小宽度水平堆叠。左边的两个元素和右边的两个元素有固定的宽度。中心包装元素宽度需要动态填充剩余宽度。中间元素有一个非常大的固定宽度的子元素。如果响应的父宽度小于固定的子宽度,我希望子程序溢出-x:滚动(隐藏剩余宽度并通过滚动查看)。
<div>
<div class="box dates"></div>
<div class="box dates_presets"></div>
<div class="box groupings"></div> <!-- to fill remaining width -->
<div class="box columns"></div>
<div class="box columns_video"></div>
</div>到目前为止我的尝试:http://jsfiddle.net/bwgrwgnz/1/ http://jsfiddle.net/hycd4non/13/
我发现这个简单的例子只适用于两个元素:http://jsfiddle.net/SpSjL/
发布于 2015-09-08 17:15:55
使用表的解决方案:http://jsfiddle.net/bwgrwgnz/41/
.box {
border: 2px dashed #00f;
height: 100px;
width: 50px;
}
.dynamic-box {
width:auto !important;
}
.dynamic-box-fixed-inner {
display:block !important;
overflow-x:scroll;
}
.inner-item {
position:inline-block;
padding:5px;
}
.table { display: table; width: 100%; table-layout:fixed; }
.tr { display: table-row; }
.tr div { display: table-cell; }
<div class="table">
<div class="tr">
<div class="box">a</div>
<div class="box">b</div>
<!-- this element should fill the remaining width -->
<div class="box dynamic-box">
<div class="dynamic-box-fixed-inner">
<div class="inner-item">item</div>
<div class="inner-item">item</div>
...
</div>
</div>
<div class="box">d</div>
</div>
</div>发布于 2015-08-21 17:39:59
尝试使用display: table | table-row | table-cell
.table { display: table; width: 100%; } /* set the width to your maximum width value */
.tr { display: table-row; }
.tr div { display: table-cell; }您还需要从“表-单元格”元素中移除所有浮点数。
发布于 2015-08-21 18:06:51
再来一种没有挠曲盒的解决方案。问题是强迫滚动。或多或少有一个肮脏的黑客成功了!
http://jsfiddle.net/d4n2fnpy/1/
#table {
display:table;
width:100%;
table-layout:fixed;
}
.box {
border: 2px dashed #00f;
min-height: 100px;
padding-right: 10px;
display:table-cell;
word-wrap:break-word;
}
.dates {
width: 200px;
}
.dates_presets {
width:200px;
}
.groupings {
overflow-x: scroll;
word-wrap:initial!important;
display:block!important;
width:auto;
}
.columns {
width:200px;
}
.columns_video {
width: 200px;
}设置溢出-x:自动;在不需要时移除丑陋的滚动器.
https://stackoverflow.com/questions/32146205
复制相似问题