0

我的中心 div 超出了它的容器,它如何占用左右之间的剩余空间?左右必须完全可见,但中心的内容可以溢出隐藏

** jsFiddle **

HTML

<div id=container>
    <div id=left>
        <div>first element</div>
        <div>second element</div>
        <div>third element</div>
    </div>
    <div id=right>right frame variable width</div>
    <div id=center>
        <div>first element</div>
        <div>second element</div>
        <div>third element</div>
    </div>
</div>

CSS

html,body{margin:0;}
*{box-sizing:border-box;}
#container {
    height:30px;
    white-space:nowrap;
    background-color:lightgreen;
}
#left {
    float:left;
    border:4px solid black;
    height:100%;
}
#left *{
    border:2px solid blue;
    display:inline-block;
    height:100%;
}
#center {
    float:left;
    border:4px solid black;
    display:inline-block;
    overflow:hidden;
    height:100%;
}
#center *{
    border:2px solid red;
    display:inline-block;
    height:100%;
}
#right {
    float:right;
    border:4px solid black;
    height:100%;
}
4

1 回答 1

2

只需从元素中删除float:leftand ..display:inline-block#center

演示在 http://jsfiddle.net/Z2x8e/8/

于 2013-11-09T19:48:11.153 回答