[英]Partially fixed header, fixed footer, and a variable width content that is scrollable in the X and Y directions as content grows
There are lots of fixed footer/header variable width content posts but none seem to work for my specific use case. 有很多固定的页脚/页眉可变宽度的内容,但似乎不适用于我的特定用例。
The easiest way to describe what I want is a google doc's style interface where the header and footer are fixed and the content is X/Y scrollable but was part of the header scrolls away when you start scrolling down 描述我想要的最简单的方法是google doc的样式界面,其中页眉和页脚是固定的,内容是X / Y可滚动的,但是当您开始向下滚动时,页眉的一部分会滚动掉
https://jsfiddle.net/zve0mb5m/ https://jsfiddle.net/zve0mb5m/
HTML, body {
width: 100%;
height: 100%;
margin: 0px;
padding: 0px;
}
div {
padding: 10px;
}
.header {
background: LightCoral;
border: 10px solid IndianRed;
}
.fixed-header {
position: sticky;
top: 0px;
background: Gold;
border: 10px solid GoldenRod;
}
.content {
overflow-y: scroll;
overflow-x: scroll;
height: 100%;
background: YellowGreen;
border: 10px solid OliveDrab;
}
.fixed-footer{
position: fixed;
bottom: 0px;
background: LightSteelBlue;
border: 10px solid SteelBlue;
width: 100%;
}
<div class="header">
<h1>Non fixed header content</h1>
</div>
<div class="fixed-header">
Fixed header content
</div>
<div class="content">
Some content that will overflow horizontally aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</div>
<div class="fixed-footer">
Fixed footer content
</div>
The above fiddle is what I have so far, in a working solution the border for the green content section would appear just above the blue footer which would allow the horizontal scroll bar to be present. 上面的小提琴是我到目前为止所拥有的,在一个可行的解决方案中,绿色内容部分的边框将出现在蓝色页脚的正上方,这将允许显示水平滚动条。
Also, when scrolling the content section goes underneath the fixed header which isn't ideal. 同样,在滚动时,内容部分位于固定标题的下面,这是不理想的。 I want the content section to be fully visible at all times, and grow as we scroll.
我希望内容部分在任何时候都是完全可见的,并随着滚动而增长。 Possible with CSS?
可以用CSS吗? Do I need some JS in here?
我这里需要一些JS吗?
您可以将固定项包装在容器div
并使用flexbox对其进行布局: http : //jsfiddle.net/38m5d13r/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.