动态宽度容器div具有固定高度和水平滚动?

Jef*_*eff 4 css containers scroll width css-float

我正在尝试获得一个容器div,它将水平滚动到视口之外.有点像#a开头和#c结尾的全屏幻灯片.两个#a#c固定宽度的div,和#b具有动态宽度的图像内容.我遇到的问题是#container动态改变其宽度以适应#b.将#container宽度设置为auto或100%只使用视口宽度.

我在追求的是什么:

[-  viewport width  -]
--#container--------------------------------------- 
|   --------------------------------------------  | 
|   | #a  |      #b...                    | #c |  |  
|   --------------------------------------------  |
--------------------------------------------------- 
Run Code Online (Sandbox Code Playgroud)

我的加价:

#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>
Run Code Online (Sandbox Code Playgroud)

编辑:我可以用表格做到这一点,但如果可能的话,我想避免这样做.

编辑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>
Run Code Online (Sandbox Code Playgroud)

Iva*_*nić 6

<div id="container">
  <div id="a">fixed width content</div>
  <div id="b">
    <img src="http://karenrothart.com/yahoo_site_admin/assets/images/Landscape_Panorama.13130817_large.jpg" />dynamic width content dynamic width content dynamic width content dynamic width content
  </div>
  <div id="c">fixed width content</div>
</div>
Run Code Online (Sandbox Code Playgroud)

这是一个很好的CSS:

div {
  height: 400px;
}

#container {
  position: relative; /* needed for absolutely positioning #a and #c */
  padding: 0 200px; /* will offset for width of #a and #c; and center #b */
  border: green 3px dotted; /* just for the show */
  float: left; /* To dynamicaly change width according to children */
}

#a, #b {
  position: absolute; /* causes #a and #b to not respect padding of #container and also gives it its place */
  top: 0;
  width:200px;
  left: 0;
}

#c {
  right: 0;
}
Run Code Online (Sandbox Code Playgroud)

漂亮而有光泽的例子:http://jsfiddle.net/KefJ2/

如果您需要多个图像而不是添加此图像:

#b {
  white-space: nowrap; /* causes all direct child elements to be in one line */
}
Run Code Online (Sandbox Code Playgroud)

更多图片的示例:http://jsfiddle.net/KefJ2/1/ 显然你将不得不玩文字和图像布局,#b但这应该很容易:)