我想要一个容器div,它能够在视口之外水平滚动。就像一个全屏的胶片条,其中#a是开头,#c是结尾。 #a和#c都是固定宽度的div,并且#b有动态宽度的图片内容。我遇到的问题是让#container的宽度动态改变以适应#b。将#container的宽度设置为auto或100%只使用视口宽度。
我想要的效果:
我想要的效果:
[- viewport width -]
--#container---------------------------------------
| -------------------------------------------- |
| | #a | #b... | #c | |
| -------------------------------------------- |
---------------------------------------------------
我的标记:
#container {
height:400px;
}
#a {
float:left;
width:200px;
height:400px;
}
#b {
float:left;
width:auto;
height:400px;
}
#c {
float:left;
width:200px;
height:400px;
}
<div id="container">
<div id="a">fixed width content</div>
<div id="b">dynamic width content</div>
<div id="c">fixed width content</div>
</div>
编辑:我可以使用表格来完成这个任务,但如果可能的话,希望避免使用表格。
编辑2:以下是使用表格的可行版本:
#container {
height:400px;
background:#fff;
}
#a {
width:200px;
height:400px;
background:#ccc;
}
#b {
height:400px;
background:yellow;
white-space: nowrap;
}
#c {
width:200px;
height:400px;
background:#ccc;
}
<table cellpadding="0" cellspacing="0">
<tr>
<td id="a">
a
</td>
<td id="b">
<img src="..." />
<img src="..." />
<img src="..." />
</td>
<td id="c">
b
</td>
</tr>
</table>
#a
、#b
和#c
垂直堆叠。 - Jeff