Compelex Flex Box Layout
I am attempting to create a full screen app interface. There should be a scrolling area in the region named 'view-with-wisdebar'. The 'content' area should also scroll so the 'options' remain static.
I am approximating the flexible height using viewport units on one of the flex box descendants. The header should be static. The main should have a flexible height with scrolling area inside it. The footer should be static.
The problem is that the contents never matches the viewport height. The 'overflow auto' element is not used. I thought I had achieved this but then I added some more header height and footer went off the bottom!
As you can see I want the header and footer fixed to the top and bottom, and I want the middle section flexible. The middle section should contain aa fixed height navbar and a flexible view area.
https://jsfiddle.net/p47o5yfe/6/
-- edit: A second link to show the desired effect approximately
https://jsfiddle.net/p47o5yfe/8/
-- edit: I have simplified the problem further
https://jsfiddle.net/p47o5yfe/10/
.wrapper {
display: flex;
flex-direction: column;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {}
.view-controller {}
.navbar {}
.view-with-sidebar {
display: flex;
flex-grow: 1;
flex-shrink: 1;
overflow: auto;
height: calc(100vh - 300px);
}
.sidebar {
width: 100px;
}
.view {
width: 100%;
}
.options {
float: left;
margin-right: 10px;
}
.content {
overflow-x: auto;
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
<div class="wrapper">
<header class="header">
Header
</header>
<main>
<div class="view-controller">
<div class="navbar">
Navbar
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar
</div>
<div class="view">
<div class="options">
Options
</div>
<div class="content">
Content
</div>
</div>
</div>
</div>
</main>
<footer>
Footer
</footer>
</div>
css flexbox
add a comment |
I am attempting to create a full screen app interface. There should be a scrolling area in the region named 'view-with-wisdebar'. The 'content' area should also scroll so the 'options' remain static.
I am approximating the flexible height using viewport units on one of the flex box descendants. The header should be static. The main should have a flexible height with scrolling area inside it. The footer should be static.
The problem is that the contents never matches the viewport height. The 'overflow auto' element is not used. I thought I had achieved this but then I added some more header height and footer went off the bottom!
As you can see I want the header and footer fixed to the top and bottom, and I want the middle section flexible. The middle section should contain aa fixed height navbar and a flexible view area.
https://jsfiddle.net/p47o5yfe/6/
-- edit: A second link to show the desired effect approximately
https://jsfiddle.net/p47o5yfe/8/
-- edit: I have simplified the problem further
https://jsfiddle.net/p47o5yfe/10/
.wrapper {
display: flex;
flex-direction: column;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {}
.view-controller {}
.navbar {}
.view-with-sidebar {
display: flex;
flex-grow: 1;
flex-shrink: 1;
overflow: auto;
height: calc(100vh - 300px);
}
.sidebar {
width: 100px;
}
.view {
width: 100%;
}
.options {
float: left;
margin-right: 10px;
}
.content {
overflow-x: auto;
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
<div class="wrapper">
<header class="header">
Header
</header>
<main>
<div class="view-controller">
<div class="navbar">
Navbar
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar
</div>
<div class="view">
<div class="options">
Options
</div>
<div class="content">
Content
</div>
</div>
</div>
</div>
</main>
<footer>
Footer
</footer>
</div>
css flexbox
I actually answered my post saying I fixed this however that is not true. I have hacked it using calc (viewport height - fixed height) jsfiddle.net/p47o5yfe/12
– Fred Stidston
Nov 22 '18 at 21:29
add a comment |
I am attempting to create a full screen app interface. There should be a scrolling area in the region named 'view-with-wisdebar'. The 'content' area should also scroll so the 'options' remain static.
I am approximating the flexible height using viewport units on one of the flex box descendants. The header should be static. The main should have a flexible height with scrolling area inside it. The footer should be static.
The problem is that the contents never matches the viewport height. The 'overflow auto' element is not used. I thought I had achieved this but then I added some more header height and footer went off the bottom!
As you can see I want the header and footer fixed to the top and bottom, and I want the middle section flexible. The middle section should contain aa fixed height navbar and a flexible view area.
https://jsfiddle.net/p47o5yfe/6/
-- edit: A second link to show the desired effect approximately
https://jsfiddle.net/p47o5yfe/8/
-- edit: I have simplified the problem further
https://jsfiddle.net/p47o5yfe/10/
.wrapper {
display: flex;
flex-direction: column;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {}
.view-controller {}
.navbar {}
.view-with-sidebar {
display: flex;
flex-grow: 1;
flex-shrink: 1;
overflow: auto;
height: calc(100vh - 300px);
}
.sidebar {
width: 100px;
}
.view {
width: 100%;
}
.options {
float: left;
margin-right: 10px;
}
.content {
overflow-x: auto;
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
<div class="wrapper">
<header class="header">
Header
</header>
<main>
<div class="view-controller">
<div class="navbar">
Navbar
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar
</div>
<div class="view">
<div class="options">
Options
</div>
<div class="content">
Content
</div>
</div>
</div>
</div>
</main>
<footer>
Footer
</footer>
</div>
css flexbox
I am attempting to create a full screen app interface. There should be a scrolling area in the region named 'view-with-wisdebar'. The 'content' area should also scroll so the 'options' remain static.
I am approximating the flexible height using viewport units on one of the flex box descendants. The header should be static. The main should have a flexible height with scrolling area inside it. The footer should be static.
The problem is that the contents never matches the viewport height. The 'overflow auto' element is not used. I thought I had achieved this but then I added some more header height and footer went off the bottom!
As you can see I want the header and footer fixed to the top and bottom, and I want the middle section flexible. The middle section should contain aa fixed height navbar and a flexible view area.
https://jsfiddle.net/p47o5yfe/6/
-- edit: A second link to show the desired effect approximately
https://jsfiddle.net/p47o5yfe/8/
-- edit: I have simplified the problem further
https://jsfiddle.net/p47o5yfe/10/
.wrapper {
display: flex;
flex-direction: column;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {}
.view-controller {}
.navbar {}
.view-with-sidebar {
display: flex;
flex-grow: 1;
flex-shrink: 1;
overflow: auto;
height: calc(100vh - 300px);
}
.sidebar {
width: 100px;
}
.view {
width: 100%;
}
.options {
float: left;
margin-right: 10px;
}
.content {
overflow-x: auto;
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
<div class="wrapper">
<header class="header">
Header
</header>
<main>
<div class="view-controller">
<div class="navbar">
Navbar
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar
</div>
<div class="view">
<div class="options">
Options
</div>
<div class="content">
Content
</div>
</div>
</div>
</div>
</main>
<footer>
Footer
</footer>
</div>
.wrapper {
display: flex;
flex-direction: column;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {}
.view-controller {}
.navbar {}
.view-with-sidebar {
display: flex;
flex-grow: 1;
flex-shrink: 1;
overflow: auto;
height: calc(100vh - 300px);
}
.sidebar {
width: 100px;
}
.view {
width: 100%;
}
.options {
float: left;
margin-right: 10px;
}
.content {
overflow-x: auto;
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
<div class="wrapper">
<header class="header">
Header
</header>
<main>
<div class="view-controller">
<div class="navbar">
Navbar
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar
</div>
<div class="view">
<div class="options">
Options
</div>
<div class="content">
Content
</div>
</div>
</div>
</div>
</main>
<footer>
Footer
</footer>
</div>
.wrapper {
display: flex;
flex-direction: column;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {}
.view-controller {}
.navbar {}
.view-with-sidebar {
display: flex;
flex-grow: 1;
flex-shrink: 1;
overflow: auto;
height: calc(100vh - 300px);
}
.sidebar {
width: 100px;
}
.view {
width: 100%;
}
.options {
float: left;
margin-right: 10px;
}
.content {
overflow-x: auto;
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
<div class="wrapper">
<header class="header">
Header
</header>
<main>
<div class="view-controller">
<div class="navbar">
Navbar
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar
</div>
<div class="view">
<div class="options">
Options
</div>
<div class="content">
Content
</div>
</div>
</div>
</div>
</main>
<footer>
Footer
</footer>
</div>
css flexbox
css flexbox
edited Nov 22 '18 at 20:58
asked Nov 22 '18 at 20:33
Fred Stidston
154
154
I actually answered my post saying I fixed this however that is not true. I have hacked it using calc (viewport height - fixed height) jsfiddle.net/p47o5yfe/12
– Fred Stidston
Nov 22 '18 at 21:29
add a comment |
I actually answered my post saying I fixed this however that is not true. I have hacked it using calc (viewport height - fixed height) jsfiddle.net/p47o5yfe/12
– Fred Stidston
Nov 22 '18 at 21:29
I actually answered my post saying I fixed this however that is not true. I have hacked it using calc (viewport height - fixed height) jsfiddle.net/p47o5yfe/12
– Fred Stidston
Nov 22 '18 at 21:29
I actually answered my post saying I fixed this however that is not true. I have hacked it using calc (viewport height - fixed height) jsfiddle.net/p47o5yfe/12
– Fred Stidston
Nov 22 '18 at 21:29
add a comment |
1 Answer
1
active
oldest
votes
If you want to put scrollbar only on content and option div (without any hardcore) you could do something like this. I didn't change your HTML, I worked only with CSS. They are all commented to a more simple understand. Hope it helps you.
* {
/* it is better if you use a normalize css (https://necolas.github.io/normalize.css/) instead of these rules that I added only for this example */
padding: 0;
margin: 0;
box-sizing: border-box;
/* end */
}
.wrapper,
.wrapper * {
margin: 2px;
padding: 2px;
background-color: rgba(50, 50, 50, 0.5) !important;
border: 1px solid black;
}
.wrapper {
display: flex;
flex-direction: column;
margin: 0; /* add this to remove the default scrollbar, you can remove this rule if it is not a problem for you */
height: 100vh;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {
flex: 1 1 auto;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
.view-controller {
display: flex; /* it is a flexbox in a flexbox in a flexbox... */
flex-direction: column;
}
.view-with-sidebar {
flex: 1 1 auto;
display: flex;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
.sidebar {
width: 100px;
}
.view {
display: flex; /* another flexbox in a flexbox... the game continues... */
flex: 1 1 auto;
}
.options {
margin-right: 10px;
min-width: 100px; /* this is an add only to read better the options content, you can remove it */
overflow-y: auto; /* this is the real overflow with scroll bar */
}
.content {
overflow-y: auto; /* this is the real overflow with scroll bar */
flex: 1 1 auto;
}
<div class="wrapper">
<header>
Header<br>
Header
</header>
<main class="view-controller">
<div class="navbar">
Navbar<br>
Navbar
</div>
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar<br>
Sidebar
</div>
<div class="view">
<div class="options">
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
</div>
<div class="content">
Content<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br>
</div>
</div>
</div>
</main>
<footer>
Footer<br>
Footer</footer>
</div>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437694%2fcompelex-flex-box-layout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
If you want to put scrollbar only on content and option div (without any hardcore) you could do something like this. I didn't change your HTML, I worked only with CSS. They are all commented to a more simple understand. Hope it helps you.
* {
/* it is better if you use a normalize css (https://necolas.github.io/normalize.css/) instead of these rules that I added only for this example */
padding: 0;
margin: 0;
box-sizing: border-box;
/* end */
}
.wrapper,
.wrapper * {
margin: 2px;
padding: 2px;
background-color: rgba(50, 50, 50, 0.5) !important;
border: 1px solid black;
}
.wrapper {
display: flex;
flex-direction: column;
margin: 0; /* add this to remove the default scrollbar, you can remove this rule if it is not a problem for you */
height: 100vh;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {
flex: 1 1 auto;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
.view-controller {
display: flex; /* it is a flexbox in a flexbox in a flexbox... */
flex-direction: column;
}
.view-with-sidebar {
flex: 1 1 auto;
display: flex;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
.sidebar {
width: 100px;
}
.view {
display: flex; /* another flexbox in a flexbox... the game continues... */
flex: 1 1 auto;
}
.options {
margin-right: 10px;
min-width: 100px; /* this is an add only to read better the options content, you can remove it */
overflow-y: auto; /* this is the real overflow with scroll bar */
}
.content {
overflow-y: auto; /* this is the real overflow with scroll bar */
flex: 1 1 auto;
}
<div class="wrapper">
<header>
Header<br>
Header
</header>
<main class="view-controller">
<div class="navbar">
Navbar<br>
Navbar
</div>
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar<br>
Sidebar
</div>
<div class="view">
<div class="options">
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
</div>
<div class="content">
Content<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br>
</div>
</div>
</div>
</main>
<footer>
Footer<br>
Footer</footer>
</div>
add a comment |
If you want to put scrollbar only on content and option div (without any hardcore) you could do something like this. I didn't change your HTML, I worked only with CSS. They are all commented to a more simple understand. Hope it helps you.
* {
/* it is better if you use a normalize css (https://necolas.github.io/normalize.css/) instead of these rules that I added only for this example */
padding: 0;
margin: 0;
box-sizing: border-box;
/* end */
}
.wrapper,
.wrapper * {
margin: 2px;
padding: 2px;
background-color: rgba(50, 50, 50, 0.5) !important;
border: 1px solid black;
}
.wrapper {
display: flex;
flex-direction: column;
margin: 0; /* add this to remove the default scrollbar, you can remove this rule if it is not a problem for you */
height: 100vh;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {
flex: 1 1 auto;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
.view-controller {
display: flex; /* it is a flexbox in a flexbox in a flexbox... */
flex-direction: column;
}
.view-with-sidebar {
flex: 1 1 auto;
display: flex;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
.sidebar {
width: 100px;
}
.view {
display: flex; /* another flexbox in a flexbox... the game continues... */
flex: 1 1 auto;
}
.options {
margin-right: 10px;
min-width: 100px; /* this is an add only to read better the options content, you can remove it */
overflow-y: auto; /* this is the real overflow with scroll bar */
}
.content {
overflow-y: auto; /* this is the real overflow with scroll bar */
flex: 1 1 auto;
}
<div class="wrapper">
<header>
Header<br>
Header
</header>
<main class="view-controller">
<div class="navbar">
Navbar<br>
Navbar
</div>
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar<br>
Sidebar
</div>
<div class="view">
<div class="options">
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
</div>
<div class="content">
Content<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br>
</div>
</div>
</div>
</main>
<footer>
Footer<br>
Footer</footer>
</div>
add a comment |
If you want to put scrollbar only on content and option div (without any hardcore) you could do something like this. I didn't change your HTML, I worked only with CSS. They are all commented to a more simple understand. Hope it helps you.
* {
/* it is better if you use a normalize css (https://necolas.github.io/normalize.css/) instead of these rules that I added only for this example */
padding: 0;
margin: 0;
box-sizing: border-box;
/* end */
}
.wrapper,
.wrapper * {
margin: 2px;
padding: 2px;
background-color: rgba(50, 50, 50, 0.5) !important;
border: 1px solid black;
}
.wrapper {
display: flex;
flex-direction: column;
margin: 0; /* add this to remove the default scrollbar, you can remove this rule if it is not a problem for you */
height: 100vh;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {
flex: 1 1 auto;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
.view-controller {
display: flex; /* it is a flexbox in a flexbox in a flexbox... */
flex-direction: column;
}
.view-with-sidebar {
flex: 1 1 auto;
display: flex;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
.sidebar {
width: 100px;
}
.view {
display: flex; /* another flexbox in a flexbox... the game continues... */
flex: 1 1 auto;
}
.options {
margin-right: 10px;
min-width: 100px; /* this is an add only to read better the options content, you can remove it */
overflow-y: auto; /* this is the real overflow with scroll bar */
}
.content {
overflow-y: auto; /* this is the real overflow with scroll bar */
flex: 1 1 auto;
}
<div class="wrapper">
<header>
Header<br>
Header
</header>
<main class="view-controller">
<div class="navbar">
Navbar<br>
Navbar
</div>
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar<br>
Sidebar
</div>
<div class="view">
<div class="options">
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
</div>
<div class="content">
Content<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br>
</div>
</div>
</div>
</main>
<footer>
Footer<br>
Footer</footer>
</div>
If you want to put scrollbar only on content and option div (without any hardcore) you could do something like this. I didn't change your HTML, I worked only with CSS. They are all commented to a more simple understand. Hope it helps you.
* {
/* it is better if you use a normalize css (https://necolas.github.io/normalize.css/) instead of these rules that I added only for this example */
padding: 0;
margin: 0;
box-sizing: border-box;
/* end */
}
.wrapper,
.wrapper * {
margin: 2px;
padding: 2px;
background-color: rgba(50, 50, 50, 0.5) !important;
border: 1px solid black;
}
.wrapper {
display: flex;
flex-direction: column;
margin: 0; /* add this to remove the default scrollbar, you can remove this rule if it is not a problem for you */
height: 100vh;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {
flex: 1 1 auto;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
.view-controller {
display: flex; /* it is a flexbox in a flexbox in a flexbox... */
flex-direction: column;
}
.view-with-sidebar {
flex: 1 1 auto;
display: flex;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
.sidebar {
width: 100px;
}
.view {
display: flex; /* another flexbox in a flexbox... the game continues... */
flex: 1 1 auto;
}
.options {
margin-right: 10px;
min-width: 100px; /* this is an add only to read better the options content, you can remove it */
overflow-y: auto; /* this is the real overflow with scroll bar */
}
.content {
overflow-y: auto; /* this is the real overflow with scroll bar */
flex: 1 1 auto;
}
<div class="wrapper">
<header>
Header<br>
Header
</header>
<main class="view-controller">
<div class="navbar">
Navbar<br>
Navbar
</div>
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar<br>
Sidebar
</div>
<div class="view">
<div class="options">
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
</div>
<div class="content">
Content<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br>
</div>
</div>
</div>
</main>
<footer>
Footer<br>
Footer</footer>
</div>
* {
/* it is better if you use a normalize css (https://necolas.github.io/normalize.css/) instead of these rules that I added only for this example */
padding: 0;
margin: 0;
box-sizing: border-box;
/* end */
}
.wrapper,
.wrapper * {
margin: 2px;
padding: 2px;
background-color: rgba(50, 50, 50, 0.5) !important;
border: 1px solid black;
}
.wrapper {
display: flex;
flex-direction: column;
margin: 0; /* add this to remove the default scrollbar, you can remove this rule if it is not a problem for you */
height: 100vh;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {
flex: 1 1 auto;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
.view-controller {
display: flex; /* it is a flexbox in a flexbox in a flexbox... */
flex-direction: column;
}
.view-with-sidebar {
flex: 1 1 auto;
display: flex;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
.sidebar {
width: 100px;
}
.view {
display: flex; /* another flexbox in a flexbox... the game continues... */
flex: 1 1 auto;
}
.options {
margin-right: 10px;
min-width: 100px; /* this is an add only to read better the options content, you can remove it */
overflow-y: auto; /* this is the real overflow with scroll bar */
}
.content {
overflow-y: auto; /* this is the real overflow with scroll bar */
flex: 1 1 auto;
}
<div class="wrapper">
<header>
Header<br>
Header
</header>
<main class="view-controller">
<div class="navbar">
Navbar<br>
Navbar
</div>
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar<br>
Sidebar
</div>
<div class="view">
<div class="options">
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
</div>
<div class="content">
Content<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br>
</div>
</div>
</div>
</main>
<footer>
Footer<br>
Footer</footer>
</div>
* {
/* it is better if you use a normalize css (https://necolas.github.io/normalize.css/) instead of these rules that I added only for this example */
padding: 0;
margin: 0;
box-sizing: border-box;
/* end */
}
.wrapper,
.wrapper * {
margin: 2px;
padding: 2px;
background-color: rgba(50, 50, 50, 0.5) !important;
border: 1px solid black;
}
.wrapper {
display: flex;
flex-direction: column;
margin: 0; /* add this to remove the default scrollbar, you can remove this rule if it is not a problem for you */
height: 100vh;
}
.header {
flex-grow: 0;
flex-shrink: 0;
}
main {
flex: 1 1 auto;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
footer {
flex-grow: 0;
flex-shrink: 0;
}
.view-controller {
display: flex; /* it is a flexbox in a flexbox in a flexbox... */
flex-direction: column;
}
.view-with-sidebar {
flex: 1 1 auto;
display: flex;
overflow-y: hidden; /* add this rule to use the last level overflow-y in content & options */
}
.sidebar {
width: 100px;
}
.view {
display: flex; /* another flexbox in a flexbox... the game continues... */
flex: 1 1 auto;
}
.options {
margin-right: 10px;
min-width: 100px; /* this is an add only to read better the options content, you can remove it */
overflow-y: auto; /* this is the real overflow with scroll bar */
}
.content {
overflow-y: auto; /* this is the real overflow with scroll bar */
flex: 1 1 auto;
}
<div class="wrapper">
<header>
Header<br>
Header
</header>
<main class="view-controller">
<div class="navbar">
Navbar<br>
Navbar
</div>
<div class="view-with-sidebar">
<div class="sidebar">
Sidebar<br>
Sidebar
</div>
<div class="view">
<div class="options">
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
Options<br>
</div>
<div class="content">
Content<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br> Content
<br>
</div>
</div>
</div>
</main>
<footer>
Footer<br>
Footer</footer>
</div>
edited Nov 22 '18 at 23:48
answered Nov 22 '18 at 23:42
ReSedano
2,6502415
2,6502415
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53437694%2fcompelex-flex-box-layout%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
I actually answered my post saying I fixed this however that is not true. I have hacked it using calc (viewport height - fixed height) jsfiddle.net/p47o5yfe/12
– Fred Stidston
Nov 22 '18 at 21:29