编辑:我的例子太复杂了。所以我做了一个简单的。
http://codepen.io/knobo/pen/gaZVoN
.top超出了html元素的可用大小。我不希望当前视口之外的任何内容为100vh,但是我不知道.bottom的高度会有所不同。
这行代码:max-height:calc(100vh-60px); 使它看起来像这样。但这不是,因为我不知道.bottom的高度,我刚刚估计为60px;
<div class="page">
<div class="top">
<div class="left">Some text</div>
<div class="right">
<img src="http://placehold.it/350x1800">
</div>
</div>
<div class="bottom">
<button>Click</button>
<button>Click</button>
<button>Could be several lines</button>
</div>
</div>
html, body {
max-height: 100vh;
}
的CSS
.page {
display: flex;
flex-direction: column;
height: 100%;
}
.top {
flex: 1 1 auto;
display: flex;
overflow: hidden;
max-height: calc(100vh - 60px);
/*
I don't know the height of .bottom
It can change when browser is resized too..
How do I solve this.
*/
}
.left {
flex: 1 1 auto;
}
.bottom {
padding: 10px;
flex: 1 1 auto;
background-color: teal;
}
EDIT2 :(包含来自第一个版本的原始链接)http://codepen.io/knobo/pen/epboBv(css版本。不起作用)http://codepen.io/knobo/pen/wKRNjr/(js版本。但是我想知道如何使用CSS。)
EDIT3截图:
这是应该的方式:div.top缩小,并且底部行仍然可见。我能够用JavaScript做到这一点。我想CSS也应该有可能。
该解决方案非常简单。
.right {
position: relative;
/* width: Do something with width here. */
}
.nooverflow {
position: absolute;
}
然后用class =“ nooverflow”包装.right的内容
<div class="right">
<div class="overflow">
{{ Content of .right }}
</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句