Popup element not scrolling all the way to bottom - html

I'm trying to figure out how to get my element to always scroll to the very end regardless of what the height of the browser is. My ultimate goal is to have a popup which does not show scroll bar, yet you can still scroll if the content exceeds the height of the popup. Lastly, I have an image at the top that needs to be half in and half out of the content (visually). Here is what i have tried:
I would suggest looking at this via the jsfiddle bellow, the result seems to be different here on SO because I have SASS code instead of CSS.
.popup-wrapper {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 100%;
max-width: 400px;
overflow: hidden;
height: 100%;
max-height: 700px;
z-index: 991;
.popup-logo {
position: absolute;
top: 0;
left: 50%;
transform: translate(-50%, 0);
z-index: 992;
}
.popup-content-wrapper {
position: absolute;
top: 50px;
left: 0;
width: 100%;
max-width: 400px;
overflow: hidden;
height: 100%;
max-height: 650px;
z-index: 991;
padding-top: 70px;
background-color: rgba(255, 255, 255, 0.9);
.popup-content {
width: calc(100% - 40px);
height: 100%;
max-height: 580px;
overflow: auto;
padding: 0 40px 20px 20px;
p {
color: #000;
}
}
}
}
<div class="popup-wrapper">
<img class="popup-logo" src="http://www.clker.com/cliparts/A/x/R/m/4/2/black-white-ying-yang-th.png" asp-append-version="true" />
<div class="popup-content-wrapper">
<div class="popup-content">
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
<p>Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo. Quisque sit amet est et sapien ullamcorper pharetra. Vestibulum erat wisi, condimentum sed, commodo vitae, ornare sit amet, wisi. Aenean fermentum, elit eget tincidunt condimentum, eros ipsum rutrum orci, sagittis tempus lacus enim ac dui. Donec non enim in turpis pulvinar facilisis. Ut felis. Praesent dapibus, neque id cursus faucibus, tortor neque egestas augue, eu vulputate magna eros eu erat. Aliquam erat volutpat. Nam dui mi, tincidunt quis, accumsan porttitor, facilisis luctus, metus</p>
</div>
</div>
</div>
Here is a jsfiddle: https://jsfiddle.net/ac1nb9qj/
As you can see in the example above, if the screen is longer than the popup than there is no issue, however if the screen height is less than the popup height, the popup doesn't quite scroll to the end of the content, some content is cut off at the bottom.
NOTE: This is using SASS (SCSS) and not regular CSS.
EDIT: To clarify, I have already achieved my scrollbar not showing, my only problem here is when I add padding to the top to put my image in, my scrolling no longer goes to the bottom. This is what I'm trying to fix. So the suggested duplicated below is wrong.

The problem is your height: 100%;. With this you say that his height is 100% of the parent height, so if the parent is 500px, is height will also be 500px without taking into account the size of the rest of the elements next to it. In this case your logo is taking some height space, so if your logo is 100px and the text container is 100% parent height (500px), you end with a parent container with size 500px containing two children than sum a total of 600px.
What you want to do is to say that "it is the height of the parent MINUS the logo height", which can be achieved with the calc CSS keyword.
.popup-content-wrapper {
height: calc(100% - 100px);
}
Fiddle: https://jsfiddle.net/y8eg65hL/
Other way is to use flexboxes (my preferred way). I suggest you to learn about them as will make your HTML design really easy for infinite reasons. In this case you can create an element where you say "fill the rest of the parent height, taking into account the size of the rest of the siblings" without effort. The CSS code will be cleaner and you will learn the future of HTML :P

Related

Footer out of screen on iphone

referring to the following question made by me where i was asking on how could i fit the content between the header and the footer by setting content height minus footer height solved the problem but actually when i try to add the web site to Home screen on any iPhone the footer goes out of screen as the following:
As you can see the footer is visible only in part and to see it i have to scroll the whole page down (not the central content but the page) while that problem doesn't persist on web or Android devices..
I've tryed to subtract more pixels to content height if the device is an iphone but it had no effect, i've tryed the following code:
if (navigator.userAgent.match(/iPhone/i)) {
$('.tableFixHead').addClass('tableFixHead-mobile');
}
.tableFixHead-mobile {
max-height: calc(100vh - 500px) !important;
}
But the view remain still the same, the whole css and html code you can see in the following jsfiddle
If I understand your question correctly, the goal is to always have the header and footer fixed and allow the content in the center to scroll. You've accomplished this with absolute positioning and calculations based on viewHeight
The problem is that the implementation of vh is extremely inconsistent on mobile devices. And these problems are unlikely to change any time soon (see this).
So, I would recommend revamping your layout to reduce the dependency on viewHeight. There are multiple ways to do this but flexbox would give you an easy solution.
Here's a minimal example of how to implement this. You'll have to apply it to your code as needed.
.contentWrapper {
/* this needs to fill the viewport
position fixed will work on modern mobile devices. */
position: fixed;
top:0; right:0; bottom:0; left:0;
/* add flex-box */
display:flex;
flex-direction:column;
}
header, footer {
background-color: darkgray;
flex-basis: 50px;
padding: 20px;
box-sizing: border-box;
}
.mainContentArea {
/* set this to fill the center space */
flex-basis: calc(100% - 100px);
/* make it scroll */
overflow-y: auto;
}
<div class="contentWrapper">
<header>Fixed Header</header>
<div class="mainContentArea">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque nec quam et imperdiet. Nullam vel euismod nisl, sed viverra magna. Cras nec ex ligula. In laoreet ornare nunc ut pellentesque. Phasellus lobortis vehicula lacus, et tempor dui scelerisque sit amet. Cras porttitor leo a mauris eleifend, sed sodales mi tempor. Morbi molestie, est sit amet consequat viverra, lacus arcu lobortis sapien, quis maximus dui sem nec erat. Nullam blandit tellus et dui lacinia aliquam. Morbi non gravida nisl, ac viverra tellus. Donec viverra diam ut malesuada bibendum. Sed vehicula orci eu enim aliquam, ac faucibus mauris molestie.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque nec quam et imperdiet. Nullam vel euismod nisl, sed viverra magna. Cras nec ex ligula. In laoreet ornare nunc ut pellentesque. Phasellus lobortis vehicula lacus, et tempor dui scelerisque sit amet. Cras porttitor leo a mauris eleifend, sed sodales mi tempor. Morbi molestie, est sit amet consequat viverra, lacus arcu lobortis sapien, quis maximus dui sem nec erat. Nullam blandit tellus et dui lacinia aliquam. Morbi non gravida nisl, ac viverra tellus. Donec viverra diam ut malesuada bibendum. Sed vehicula orci eu enim aliquam, ac faucibus mauris molestie.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque nec quam et imperdiet. Nullam vel euismod nisl, sed viverra magna. Cras nec ex ligula. In laoreet ornare nunc ut pellentesque. Phasellus lobortis vehicula lacus, et tempor dui scelerisque sit amet. Cras porttitor leo a mauris eleifend, sed sodales mi tempor. Morbi molestie, est sit amet consequat viverra, lacus arcu lobortis sapien, quis maximus dui sem nec erat. Nullam blandit tellus et dui lacinia aliquam. Morbi non gravida nisl, ac viverra tellus. Donec viverra diam ut malesuada bibendum. Sed vehicula orci eu enim aliquam, ac faucibus mauris molestie.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque pellentesque nec quam et imperdiet. Nullam vel euismod nisl, sed viverra magna. Cras nec ex ligula. In laoreet ornare nunc ut pellentesque. Phasellus lobortis vehicula lacus, et tempor dui scelerisque sit amet. Cras porttitor leo a mauris eleifend, sed sodales mi tempor. Morbi molestie, est sit amet consequat viverra, lacus arcu lobortis sapien, quis maximus dui sem nec erat. Nullam blandit tellus et dui lacinia aliquam. Morbi non gravida nisl, ac viverra tellus. Donec viverra diam ut malesuada bibendum. Sed vehicula orci eu enim aliquam, ac faucibus mauris molestie.</p>
</div>
<footer>Fixed Footer</footer>
</div>
.footer {
z-index: 9;
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
line-height: 60px;
background-color: #f5f5f5;
}
The above is your code. Just change from position:absolute to position:fixed.
Run the following snippet, if your question was correctly understood then the result is the visual effect you want to achieve. If yes, then check the dimensions of the elements and their position in the code below.
* {
margin: 0;
padding: 0;
}
body {
display;
flex;
align-items: center;
align-content: center;
justify-content: stretch;
flex-direction: column;
text-align: center;
width: 100%;
height: 100%;
}
header,
footer {
background: #000;
color: #fff;
height: 3rem;
width: 100%;
}
main div {
padding: .5rem 0;
}
main {
background: orange;
width: 100%;
min-height: calc(100% - 6rem);
height: auto;
position: relative;
top: 3rem;
margin-bottom: 2rem;
overflow: hidden;
}
main p {
height: 2rem;
}
header {
position: fixed;
top: 0;
z-index: 1;
}
footer {
position: fixed;
top: calc(100% - 3rem);
}
<header>this is header content</header>
<main>
<div>
<p>1</p>
<p>2</p>
<p>3</p>
<p>4</p>
<p>5</p>
<p>6</p>
<p>7</p>
<p>8</p>
<p>9</p>
<p>10</p>
<p>11</p>
<p>12</p>
<p>13</p>
<p>14</p>
<p>15</p>
<p>16</p>
<p>17</p>
<p>18</p>
<p>19</p>
<p>20</p>
</div>
</main>
<footer>this is footer content</footer>
Reading this SO it seems that when setting position: absolute, you must add left: 0 and right: 0 properties to .footer in order that the bottom: 0 will work on iphone and ipad.
Didn't test it myself yet, but it was upvoted so i guess someone else found that useful.
After digging more SO's i found also this that related to this issue.
Worth to mention that caniuseit shows that from version 11 there is full support of absolute position and they not mention any sort of the above..
I guess you will test it before me, hope that will do it.
EDIT: As those SO that i linked above (also) mention, and also following the docs, in order for the position: absolute would work as expected, it parent element should have any position - and that make sens.
Seems that form id="form" is the parent (base on this fiddle), so i would add position: relative; to body itself.
Hope that will work.. Can't test it myself.

Centre a background:url image with :after pseudo element in CSS

In CSS, how do I,
1) use an :after pseudo element to successfully insert,
2) a background:url image after some text,
3) that is always centred whenever viewed on a wide large screen or tall small screen?
(Example images below.)
I’ve tried different things with the code below, but it always aligns the image with the left side of the text, instead of remaining centred as the screen size changes.
Appreciate some help please.
Code
div:after {
content: '';
background:url("https://ippcdn-ippawards.netdna-ssl.com/wp-content/uploads/2018/07/34-1st-PANORAMA-Mateusz-Piesiak-1.jpg");
width: 1200px;
height: 474px;
display: block;
}
Images
Not correct.
This is the current result with above code.
Correct.
Expected result with centre aligned image on wide large screen.
Correct.
Expected result with centre aligned image on tall small screen.
I was able to achieve your desired result by putting the text within a p > span tag, and applying the :after element to the outer p. Then, I gave the span element a max-width and centered it, so that the image appears to overflow the span container. See my solution:
p:first-of-type:after {
content: '';
background:url("https://ippcdn-ippawards.netdna-ssl.com/wp-content/uploads/2018/07/34-1st-PANORAMA-Mateusz-Piesiak-1.jpg");
width: 1200px;
height: 474px;
display: block;
max-width: 100%;
margin: 10px 0;
}
span {
display: block;
max-width: 70%;
margin: 0 auto;
}
<p><span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris eu ipsum eget elit egestas ultrices. Sed dui mauris, efficitur sit amet malesuada at, dictum quis elit. Pellentesque ac placerat ante. Nulla augue arcu, blandit quis nulla vitae, posuere gravida neque. Aenean leo erat, porttitor maximus nunc non, mollis ultrices dui. Maecenas consectetur eleifend ligula, quis rutrum leo suscipit id. Morbi pulvinar et est sit amet lacinia.</span></p>
<p><span>Nulla vitae magna at mi tempus cursus. Vestibulum purus purus, facilisis a lectus ac, gravida porta tellus. Integer auctor justo at tempus ultricies. Mauris ut eleifend nibh. Nullam fermentum dui in sem congue semper. Quisque eget pharetra enim. Aliquam erat volutpat. Donec nec fringilla augue, sed blandit neque. Aliquam sollicitudin, ante id accumsan fermentum, urna turpis lacinia metus, a ullamcorper enim velit vitae diam.</span></p>

Why isn't display:flex allowing my sidebar to take 100% of the available DIV height?

Ok, CSS gurus. Here's an easy one for you. I want to have a sidebar to the left of my main content area. I'd like the sidebar to take up 30% of the screen and the content to take up 70%. However, I'd like the sidebar area to take up 100% of the available height. I have
<div id="main">
<div id="side">
<%= render "layouts/sidebar" %>
</div>
<div id="contentArea"><%= yield %></div>
</div>
I thought setting the parent DIV to have "display:flex;" would make everything right ...
#main {
display: flex;
width: 100%;
background-color: green;
}
#side {
background-color: #e0e0e0;
width: 30%;
display: inline-block;
float: left;
height: 100%;
}
#contentArea {
text-align: center;
width: 70%;
display: inline-block;
}
but right now, the height of my sidebar is only equal to the content that's in it. How do I make it 100% of everything?
In your structure ‘main’ is parent div, that’s mean if you set ‘100% of everything’ to child div ‘side’ and this div not position absolute or fixed, ‘main’ get 100% too.
So, you can use relative lengths, like height: 100vh.
jsfiddle
But you can set to side div position fixed: it will help when you get scroll in contentArea, but side div all time will in left side with height 100vh.
jsfiddle
Tip: if you use flex, you can manipulate without float (e.g. justify-content
). Check it: https://css-tricks.com/snippets/css/a-guide-to-flexbox/
The problem is that you specified a height of 100% on #side. Ironically, this actually prevents the column from taking up the full vertical space, as it caps to at the height of the container. Because #main doesn't have a specified height, setting height: 100% on #side will constrain it to the height of the content (text) within.
Simply removing this causes the column to expand to take up the full vertical space:
#main {
display: flex;
width: 100%;
background-color: green;
}
#side {
background-color: #e0e0e0;
width: 30%;
display: inline-block;
float: left;
/*height: 100%;*/
}
#contentArea {
text-align: center;
width: 70%;
display: inline-block;
}
<div id="main">
<div id="side">
Side
</div>
<div id="contentArea">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque ut interdum quam. Integer nec tincidunt erat, in scelerisque turpis. Pellentesque interdum turpis eu ante gravida, a auctor lacus pulvinar. Maecenas elementum massa ac felis gravida lobortis
vitae eget nisi. Donec erat turpis, condimentum et ipsum in, tincidunt fringilla quam. Nam est dui, porttitor eget nisl sit amet, mollis varius dui. Suspendisse dui mauris, tincidunt vitae blandit ac, consectetur sed ex. Sed bibendum felis ex, id
euismod odio euismod ac. Praesent viverra arcu quis arcu condimentum, eget varius elit suscipit. Donec tempus, justo vel iaculis vehicula, risus magna varius ex, vitae mattis elit turpis ac magna. Fusce porta tempus erat vel ultricies. Suspendisse
vel erat blandit, semper dui sed, consequat urna. Pellentesque ultrices pellentesque feugiat. Donec sit amet turpis in orci accumsan blandit. In tincidunt erat sed tristique sagittis. Duis ultrices lacus quis vestibulum venenatis. Maecenas et risus
quam. Quisque semper purus id mauris gravida dictum. Cras tellus augue, sollicitudin ac maximus eget, porta elementum elit. Fusce vulputate consectetur dapibus. Praesent semper augue lacus, vel laoreet tellus ultricies fermentum. Phasellus vestibulum
fringilla purus ut malesuada.
</div>
</div>
Hope this helps! :)
Use: #side{height: 100vh;} (vh = viewport height), and remove display flex so you can have unequal height for each div.
Link to jsfiddle https://jsfiddle.net/gcoh62o6/5/

Position a fixed div below another fixed div with variable height without using jquery

I have a fixed top div with variable height. All I need is to push the bottom contents below the fixed div to re-position itself as the height of the fixed div changes in various pages.
P.S. I'm currently doing it with jquery but it takes some rendering time and shows broken contents until the page loads completely as it is added at the end of body tag. I want to load jquery and other scripts at the very end so trying to find a way to do this completely with CSS if possible for getting rid of those rendering effects.
Following is a demo code which needs to work with CSS only -
.container {
width: 100%;
height: auto;
}
.top {
position: fixed;
height: auto;
width: 100%;
background-color: black;
color: white;
top: 0;
}
.bottom {
height: auto;
width: 100%;
}
<div class="container">
<div class="top">
This is a fixed div with variable height and the bottom content are supposed to pushed and stayed below as the height increases.
</div>
<div class="bottom">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vestibulum consectetur porttitor neque at vestibulum. Nulla facilisi. Nullam tempus ligula sapien, dictum scelerisque libero tristique et. Ut sit amet magna eros. Suspendisse potenti. Donec vitae sodales nunc. Nunc eget condimentum urna. Nulla sit amet lectus ac nunc mattis porttitor eget quis purus. Ut rhoncus nulla eget velit tincidunt luctus. Donec in justo tempus, porttitor magna nec, semper eros. In bibendum magna eget lectus viverra ultricies. Integer pharetra augue lorem, eu tempus nulla volutpat dignissim.
Morbi vulputate arcu sit amet lectus porttitor hendrerit. Donec id pharetra urna, sit amet tincidunt nulla. Nam semper felis vitae odio elementum posuere. Vivamus blandit accumsan sapien, vitae blandit est lacinia et. Nam sit amet diam massa. Quisque et erat et orci dignissim congue. Maecenas pellentesque pretium sodales. Donec pellentesque rhoncus tortor et hendrerit. Phasellus nec dictum mi. Interdum et malesuada fames ac ante ipsum primis in faucibus. Fusce nec ligula mollis, iaculis est a, lobortis est. Phasellus faucibus varius arcu, eget volutpat quam venenatis vel. Sed felis nulla, pulvinar ut metus ac, luctus finibus tortor. Aliquam vulputate, nulla quis accumsan pretium, lacus elit sollicitudin ipsum, non faucibus erat mauris a felis.
</div>
</div>
try this
.bottom {
height: auto;
width: 100%;
margin-top: 1cm;
}
I have updated the fiddle and its working:https://jsfiddle.net/m0615z32/1/
Below is a pure javascript code that will work for you. Please check
What i have done is set the padding-top of below container to be equal to height of top container without using jquery.
document.getElementById("bottom-div").style.paddingTop = document.getElementById("top-div").clientHeight+"px";
OR
If You can change your top container to be relative than fixed, then also this works but is not keeping the div fixed on top
.top {
position: relative;
height: auto;
width: 100%;
background-color: black;
color: white;
top: 0;
}
Now the top content will always be on top. It will adjust according to content and below container will start after top ends.

Positioning multiple sections with independent overflows in HTML

I'm constructing a page that contains multiple different sections that all change contents dynamically, but I want them to be a fixed size and show a scroll bar (for only that section) if there is an overflow.
In practice I have three primary sections (div); two which should satisfy the fixed size and overflow properties, and one that acts as a footer and should be fixed to the bottom of the screen and never change size.
My problem is that I can't seem to figure out how to order and position these sections without them overlapping each other or the overflow not working as intended.
Basically I want the footer to just occupy the space it needs but always be bounded to the bottom of the screen. The other two sections should then occupy 50% of the rest of the page each. There should never be a need for a scroll bar to the page itself - but rather one for each of the two sections, since their contents vary and can overflow.
I have tried many different solutions, but here is a simplified example on what I have been working with:
Very quick mock up
<div id="page" style="position:relative; margin-top:45px">
<div id="wrapper" style="height:100%; margin-bottom:3.5em">
<div id="block-a" style="height:50%; overflow: auto; padding:0; position:relative">
<h2>...</h2>
<br/>
<div id="dynamicGrid"></div>
<br/>
<button>...</button>
</div>
<div id="block-b" style="height:50%; padding:0; position:relative">
<div style="padding-bottom:0">
<ul id="listHeader">
<li id="header">...</li>
<li id="addNew">
<a>...</a>
</li>
</ul>
</div>
<div id="listSection" style="overflow: auto">
<ul id="list"></ul>
</div>
</div>
</div>
<div id="footer" style="position:fixed; left:0; right:0; bottom:0">
<ul>
<li>
<label>...</label>
<label>...</label>
<label>...</label>
</li>
</ul>
</div>
</div>
The 'page' div is positioned relative to the body with also contains the header (45 px from top). The list with id 'list' is the list that gains list elements dynamically, and the div 'dynamicGrid' contains a bunch of selects, inputs and labels.
The div 'listSection' is what I want to overflow independently and this is the case for 'block a' as well.
A big problem I keep encountering is that I can't seem to define the space left after the footer has been created. In theory I want something like height:100%-sizeOf(footer)...
An important rule as well, is that this page has to work in most major browsers, and has to 'work' on different screen sizes (I want to avoid using px too much, but rather %)
For now I use inline html styling, but an answer using CSS is also fine.
I use JavaScript and Jquery to control the page, but the layout should be set using html.
There are two methods of doing this:
JavaScript / jQuery
Plain CSS (uses vh, but IE support is sketchy)
Method 1
JavaScript / jQuery
Check out this JSFiddle
Basically it uses jQuery to calculate the height of the body and remove the height of the footer, then it divides that by 2 to get the height of each block
Here is the JavaScript / jQuery code:
// Set the height of the #page element to be the full height of the window
$('#page').height($(window).height() + 'px')
// Save page height
var page_height = $('#page').height()
// Save page height - footer height
var height_without_footer = page_height - $('#footer').height()
// Calculate the size of each block
var block_height = height_without_footer / 2
// Set each block height
$('.block').css('height', block_height + 'px')
Here was the CSS I used (it is pretty much what you had, just in a stylesheet rather than inline). The only thing I changed was I added overflow: scroll to make sure the .blocks got scroll bars and did not resize, or their content overlap:
#footer {
background-color: #000;
color: #FFF;
position: fixed;
left: 0;
right: 0;
bottom: 0;
}
.block {
overflow: scroll;
padding: 5px;
}
/* Just to remove default CSS added by JSFiddle and browsers */
body, h1 {
margin: 0;
}
Method 2
Plain CSS (vh)
You can also use Viewport Units (set size relative to viewport), but IE support is sketchy
Here is a JSFiddle
It uses the following CSS:
#footer {
background-color: #000;
color: #FFF;
position: fixed;
left: 0;
right: 0;
bottom: 0;
height: 10vh;
}
.block {
overflow: scroll;
padding: 5px;
height: 45vh;
}
/* Just to remove default CSS added by JSFiddle and browsers */
body, h1 {
margin: 0;
}
The vh stands for Viewport Height (you can also use vw for Viewport Width). The units must all add up to < or == to 100.
In this case each .block is 45vh, there are 2 blocks so 45 * 2 is 90
The #footer is 10vh
90vh + 10vh is 100vh, meaning the page will never be larger than the viewport.
Is this what you are looking for? Use width in vw unit so as to make it adaptable to any viewport width. Height can be dynamically calculated and assigned using jQuery.
$(document).ready(function() {
var windowHeight = $(window).height();
var footerHeight = $('#footer').height();
$('#container').height((windowHeight - footerHeight) + 'px');
$('#container1').height((windowHeight - footerHeight) / 2 + 'px');
$('#container2').height((windowHeight - footerHeight) / 2 + 'px');
});
body {
margin: 0px;
padding: 0px;
}
#footer {
position: absolute;
width: 100vw;
height: auto;
bottom: 0;
background: #ccc;
}
#container {
position: realtive;
}
#container1 {
width: 100vw;
background: #f1f1f1;
overflow: scroll;
}
#container2 {
width: 100vw;
background: #444;
color: white;
overflow: scroll;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="container">
<div id="container1">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper, nunc ac hendrerit imperdiet, risus est fermentum dui, a ornare lorem justo imperdiet diam. Proin id vestibulum nisl. Suspendisse potenti. Aenean eu elit hendrerit, semper sapien
nec, dignissim lorem. Quisque urna ante, hendrerit sed eros a, consequat viverra massa. Nulla egestas est quis sem scelerisque congue. Praesent faucibus sapien eros, et gravida ligula interdum eu. Proin aliquet urna eget convallis auctor. Donec ullamcorper
cursus fringilla. Morbi dapibus lorem in nisl vestibulum, volutpat tristique urna sagittis. Nunc id condimentum sem. Donec pulvinar vestibulum convallis. Vivamus sit amet orci ante. Donec pulvinar, libero at interdum feugiat, neque sem imperdiet turpis,
venenatis maximus ante justo nec augue. Praesent a hendrerit felis, sed mollis nulla. Aliquam fermentum accumsan leo, quis pulvinar mi egestas a. Aenean non odio mollis dui porta volutpat. Integer semper ante ac ligula vulputate pharetra. Pellentesque
et scelerisque leo. Aliquam congue blandit metus, quis interdum felis. Fusce suscipit ac leo in hendrerit. Nulla semper tempus felis finibus eleifend. In quis orci nunc. Donec imperdiet tellus et cursus semper. Vivamus mauris sem, dapibus at porta
viverra, mattis ut lorem. Suspendisse eleifend commodo nisl ultricies convallis. In fringilla mauris in urna elementum venenatis.
</div>
<div id="container2">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed ullamcorper, nunc ac hendrerit imperdiet, risus est fermentum dui, a ornare lorem justo imperdiet diam. Proin id vestibulum nisl. Suspendisse potenti. Aenean eu elit hendrerit, semper sapien
nec, dignissim lorem. Quisque urna ante, hendrerit sed eros a, consequat viverra massa. Nulla egestas est quis sem scelerisque congue. Praesent faucibus sapien eros, et gravida ligula interdum eu. Proin aliquet urna eget convallis auctor. Donec ullamcorper
cursus fringilla. Morbi dapibus lorem in nisl vestibulum, volutpat tristique urna sagittis. Nunc id condimentum sem. Donec pulvinar vestibulum convallis. Vivamus sit amet orci ante. Donec pulvinar, libero at interdum feugiat, neque sem imperdiet turpis,
venenatis maximus ante justo nec augue. Praesent a hendrerit felis, sed mollis nulla. Aliquam fermentum accumsan leo, quis pulvinar mi egestas a. Aenean non odio mollis dui porta volutpat. Integer semper ante ac ligula vulputate pharetra. Pellentesque
et scelerisque leo. Aliquam congue blandit metus, quis interdum felis. Fusce suscipit ac leo in hendrerit. Nulla semper tempus felis finibus eleifend. In quis orci nunc. Donec imperdiet tellus et cursus semper. Vivamus mauris sem, dapibus at porta
viverra, mattis ut lorem. Suspendisse eleifend commodo nisl ultricies convallis. In fringilla mauris in urna elementum venenatis.
</div>
</div>
<div id="footer">
Footer
</div>