html - css - 溢出 : hidden in div nested inside display: table-cell

标签 html css overflow css-tables

我在嵌套在另一个具有 display: table-cell 样式的 div 中的 div 中遇到溢出问题。我不确定为什么 #left-wrapper 的内容在超过 #left-wrapper 的高度时不会被裁剪(隐藏)。在此先感谢您的任何建议。 fiddle 链接:http://jsfiddle.net/bpbHY/1/

这是我的标记:

<div id="wrapper">
    <div id="left">
        <div id="left-wrapper">
            <ul>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item</li>
                <li>Menu item </li>
            <ul>
        </div>
    </div>
    <div id="center">Center content</div>
    <div id="right">right</div>
</div>

CSS:

#wrapper {
    display:table;
    width:100%;
    height:100%;
}
#wrapper > div {
    display:table-cell;
    height:100%;
}
#left {
    width:70px;
    min-width:80px;
    height: 100%;
    background-color:pink;
}

#left-wrapper {
    overflow: hidden;
    height: 100%;
}

#center {
    background-color:green;
    min-width:200px;
}
#right {
    width:50px;
    min-width:50px;
    background-color:red;
}
li {
    line-height: 80px;
}
body, html {
    width:100%;
    height:100%;
}

最佳答案

overflow: hidden 不起作用,因为您正在使用 display: tabledisplay: table-cell。我还使用定位来使#center 居中。

这是 working fiddle

PS:我正在使用 min-width: 200px,您可能希望根据需要进行更改。

关于html - css - 溢出 : hidden in div nested inside display: table-cell,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18205064/

相关文章:

php - 在 mySQL 数据库中插入 HTML 数据

PHP 生成的输入和标准 DOM 输入显示不同

html - 如何删除正文周围的边距空间或清除默认的 css 样式

css - 附加 CSS、JS、Bootstrap CDN 版本后,只有一个文件未正确呈现

html - 如果文本溢出到 2 行,则添加换行符

html - Chrome 自动格式化 input=number

jquery - 使用 jquery 从 anchor onclick 更改图像 src?

php - 偏移量 0 对 MySQL 结果索引 10 无效,无法从 mysql php 检索数据

c - 如何检查值是否适合类型?

css - 如何包含元素的宽度使其不溢出主体但可见?