我正在制作一个网络应用程序,目前我正在尝试完成基本设计。所以页面上应该有几列应该能够在 x 轴上浮动。它们现在的宽度是静态的,它们的高度将是浏览器窗口的 100%。这是一个 JSFiddle:http: //jsfiddle.net/qAUXQ/
在这些列中,应该有垂直居中的内容。但是,如果某一列的内容高于浏览器窗口,则应该出现滚动条。问题是,由于高度是动态的,我能想到的唯一方法(并在 Google 上找到)就是使用该display: table方法。
问题是 div 上的滚动条不起作用。所以当浏览器窗口太小时,用户根本看不到它。它不能滚动!
如果您不想使用 JSFiddle,下面是代码:
<div class="bar">
    <div class="middle">
        <div class="contents">
            <p>Lorem Ipsum</p>
            <p>Lorem Ipsum</p>
            <p>Lorem Ipsum</p>
            <p>Lorem Ipsum</p>
            <p>Lorem Ipsum</p>
            <p>Lorem Ipsum</p>
        </div>
    </div>
</div>
CSS:
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}
body {
    background: #f4f1ed;
}
.bar {
    height: 100%;
    border-style: solid;
    width: 360px;
    display: table;
    border-width: 0 1px;
    border-color: #ddd;
    position: absolute;
    transition: left 500ms;
    -moz-transition: left 500ms;
    -webkit-transition: left 500ms;
    -o-transition: left 500ms;
    z-index: 10;
    background: #f2f2f2;
}
.bar div.middle {
    display: table-cell;
    vertical-align: middle;
}
.bar div.contents {
    padding-left: 60px;
    overflow-y: scroll;
    overflow-x: hidden;
}