I have a page that has three main section:
project-arrow-box
white-green
light-gray
project-arrow-box and light-gray are on the left side of the page and white-green is on the right. I am wanting light-gray and white-green's bottom to meet at the same point and touch my footer. My white-green's section will change size based if validation errors are made or whatever the case may be. On different screen sizes these two divs (light-gray and white-green) very in placement. Sometimes light-gray surpasses white-green and vise versa. Again, I want the end/bottom of those two divs to touch my footer regardless of the screen size.
I have tried adding bottom: 0; to both of light-gray and white-green, but this did not help. I have white-green's height set to auto, so it adapts to the expanding nature of this div. This happened before the footer, so the footer has nothing to do with any of these issues.
What can I do so this becomes possible?
.project_arrow_box {
position: relative;
/*background: rgb(69,186,149);*/
background: #00a16d;
border: 4px solid #00a16d;
width: 33%;
height: 800px;
z-index: 99;
}
#project-content-wrap {
margin: 30% 13%;
}
.white-green {
background-color: rgb(241, 250, 247);
width: 66.56%;
height: auto;
z-index: 55;
margin-left: 33.4%;
margin-right: 0;
position: absolute;
top: 0;
right: 0;
text-align: center;
}
#white-green-section {
position: relative;
left: 30%;
text-align: center;
opacity: 0;
}
.light-gray {
background-color: #E0E0E0;
width: 33.5%;
padding-top: 150px;
bottom: 0;
margin-bottom: 0;
}
.light-gray-container {
left: 15%;
position: relative;
width: 80%;
height: auto;
padding-bottom: 40px;
}
<div class="project_arrow_box">
<div id="project-content-wrap">
</div>
</div>
<div class="white-green">
<div id="white-green-section">
</div>
</div>
<div class="light-gray">
<div class="light-gray-container">
</div>
</div>
You can do this with Flexbox
body, html {
margin: 0;
padding: 0;
}
.container {
display: flex;
}
.left {
display: flex;
flex-direction: column;
flex: 0 0 33%;
}
.one {
background: #A1EB88;
flex: 100vh;
}
.two {
flex: 100vh;
background: #F2BB7C;
}
.three {
background: lightblue;
flex: 1;
}
footer {
height: 50px;
background: red;
width: 100%;
}
<div class="container">
<div class="left">
<div class="one">One</div>
<div class="two">Two</div>
</div>
<div class="three">Three</div>
</div>
<footer>Footer</footer>
Using Flexbox is likely the simplest way to pull that off:
HTML:
<div class="container">
<div class="left-container">
<div class="project-arrow-box">
<p>
</p>
</div>
<div class="light-grey">
<p>
</p>
</div>
</div>
<div class="white-green">
<p>
</p>
</div>
</div>
<div class="footer">
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Eos, vero?
</p>
</div>
CSS:
.container, .left-container, .white-green {
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6, BB7 */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
display: flex; /* NEW, Spec - Firefox, Chrome, Opera */
margin: 0;
}
.left-container {
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
display: flex;
flex-direction: column;
}
.project-arrow-box {
background-color: white;
flex-grow: 1;
padding: 1em;
}
.light-grey {
background-color: #aaa;
flex-grow: 1;
padding: 1em;
}
.white-green {
background-color: #ccFFcc;
flex-grow: 1;
padding: 1em;
}
.footer {
background-color: #000;
color: #fff;
}
See: https://jsfiddle.net/bL2ymhps/1/
Related
I would like to achieve circle cuts/hollows in the layer that covers the background images.
I have the background image covered with white tint (opacity 60%).
On the background, I have 3 circles that include text.
How can I cut "rings" in the white tint?
I would like to make hollows/cuts in the white tint like here:
My code looks now as below:
body {
margin: 0;
}
.block {
position: relative;
width: 100%;
}
.bg {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: -3;
}
.bg:before {
content: "";
background: #ffffff;
opacity: 0.6;
position: absolute;
top: 0;
left: 0;
display: block;
width: 100%;
height: 100%;
}
.bg img {
display: block;
object-fit: cover;
object-position: center;
width: 100%;
height: 100%;
}
.wrapper {
min-height: 100vh;
display: flex;
justify-content: center;
align-items: center;
gap: 0 30px;
}
.item {
background: #aaaaaa;
width: 150px;
height: 150px;
border-radius: 100%;
display: flex;
flex-direction: columns;
justify-content: center;
align-items: center;
padding: 10px;
}
.item h2 {
font-family: Arial, sans-serif;
font-size: 15px;
color: #000000;
text-align: center;
margin: 0;
}
<section class="block">
<div class="bg">
<img src="https://i.picsum.photos/id/98/1920/1080.jpg?hmac=38vHAR4QCfR9YGpaasbQ0h390ZJnDlnQqzv3xTDF6ik" alt="" />
</div>
<div class="wrapper">
<div class="item">
<div class="item__content">
<h2>Heading 1</h2>
</div>
</div>
<div class="item">
<div class="item__content">
<h2>Heading 2</h2>
</div>
</div>
<div class="item">
<h2>Heading 3</h2>
</div>
</div>
</section>
You can do it like below. I have simplified the code as well:
body {
margin: 0;
}
section {
min-height: 100vh;
/* a grid container with 3 columns*/
display: grid;
grid-template-columns: 1fr 1fr 1fr;
/* the image as background */
background: url(https://i.picsum.photos/id/98/1920/1080.jpg?hmac=38vHAR4QCfR9YGpaasbQ0h390ZJnDlnQqzv3xTDF6ik) center/cover;
}
.item {
overflow: hidden; /* hide the overflow of the shadow */
/* center the heading */
display: grid;
place-items: center;
/**/
}
.item h2 {
width: 80%; /* adjust this to control the size */
aspect-ratio: 1; /* keep it a perfect circle */
box-sizing: border-box;
border-radius: 50%;
/* center the content of the heading */
display: grid;
place-items: center;
/**/
padding: 20px; /* this will control the inner space */
background: rgb(255 255 255/60%) content-box; /* color only the content area */
box-shadow: 0 0 0 100vmax rgb(255 255 255/60%); /* a big box-shadow */
}
<section>
<div class="item">
<h2>Heading 1</h2>
</div>
<div class="item">
<h2>Heading 2</h2>
</div>
<div class="item">
<h2>Heading 2</h2>
</div>
</section>
I am struggling with a flexbox tag here. I have a page header, that consists from two parts: smaller text "A comprehensive manual:" and "How to take a dog from UK to SOME OTHER COUNTRY".
So the problem is, according to design document, "How to take a dog from UK to SOME OTHER COUNTRY" should be centred, but "A comprehensive manual" line shouldn't, it should start right above letter "H" in the second line, "How to take...", as shown on a picture below:
here
Obviously, when I resize a window, flexbox starts doing it thing and wars text around, changing the position of the "How", however "A comprehensive manual" should also move to keep along.
Is it possible with a flexbox, or I should use ::after pseudoelement to achieve it? Or maybe there is better solution?
Code is below, there is also a link to the codepen with an example.
Many thanks!
<div class="take-where-box">
<div class="flex">
<div class="take-where-box__text-block large" id="take-where-box__text-block-intro"><p class="take-where-box__small-text">A Comperhensive Manual:</p></div>
<div class="take-where-box__text-block" id="take-where-box__text-block-1"><p>How to take a dog</p></div>
<div class="take-where-box__text-block" id="take-where-box__text-block-2"><p>from UK</p></div>
<div class="take-where-box__text-block" id="take-where-box__text-block-3">
<div class="select-box">
/*code for select box*/
</div> <!-- end of select-box-->
</div>
</div>
</div> <!-- take-where-box-->
Full codepen is here:
https://codepen.io/abby97/pen/oNYjrpV
Perhaps the layout can be achieved with a minor adjustment to the align-items property and a pseudo element.
.flex {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: flex-end; /* changed from baseline */
}
#take-where-box__text-block-1::before {
font-size: 70%;
content: "A Comprehensive Manual:";
}
#take-where-box__text-block-1::before {
font-size: 70%;
content: "A Comprehensive Manual:";
}
body,
html {
margin: 0;
padding: 0;
font-family: 'Calibri', serif;
font-size: 100%;
color: black;
background-color: var(--cyan-superdark);
}
.container {
background-color: var(--main_color);
margin: 0 auto;
width: 80%;
}
.header,
.content {
margin: 0;
display: flex;
flex-direction: column;
align-items: center;
}
.header {
background-color: var(--yellow-main);
}
.content {
background-color: var(--cyan-superdark);
}
.take-where-box {
font-size: 3rem;
justify-content: center;
align-items: center;
font-weight: bold;
width: 90%;
border: 0.4rem solid black;
padding: 1.5rem;
}
.flex {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-content: center;
align-items: flex-end;
}
.take-where-box__small-text {
font-size: 70%;
margin: 0;
}
.take-where-box__text-block {
flex-basis: 1;
/* flex-shrink: 0; */
/* min-width: min-content; */
padding: 0 0.5rem;
}
.large {
flex-basis: 100%;
}
.take-where-box__text-block>p {
margin: 0;
}
/*select-box - a custom select box, taken from https://www.youtube.com/watch?v=k4gzE80FKb0 */
.select-box {
display: flex;
flex-direction: column;
position: relative;
width: 22rem;
}
.select-box__selected-option,
.select-box__options-container {
border: 0.4rem solid black;
}
.select-box .select-box__options-container {
max-height: 0;
opacity: 0;
transition: all 0.3s;
/* what are other options? */
order: 1;
}
.select-box__selected-option {
margin-bottom: 8px;
position: relative;
order: 0;
}
.select-box__options-container {
position: absolute;
box-sizing: border-box;
/*otherwise border will add up to the witdh of this element making it bigger than parent, BAD!*/
width: 100%;
top: 7.5rem;
background-color: white
}
.select-box__selected-option::after {
content: "";
background: url("assets/arrow-down.svg");
background-size: contain;
background-repeat: no-repeat;
position: absolute;
height: 100%;
width: 3.0rem;
/* height: 4rem; */
right: 1rem;
top: 1rem;
transition: all 0.4s;
}
.select-box .select-box__options-container.active+.select-box__selected-option::after {
transform: rotateX(180deg);
top: -1rem;
}
.select-box .select-box__options-container.active {
max-height: min-content;
opacity: 1;
}
.select-box .select-box__option,
.select-box__selected-option {
padding: 0.5rem 1rem;
cursor: pointer;
}
.select-box .select-box__option:hover {
background-color: blue;
}
.select-box label {
cursor: pointer;
}
.select-box .select-box__option .radio {
display: none;
}
<div class="container">
<div class="take-where-box">
<div class="flex">
<div class="take-where-box__text-block large" id="take-where-box__text-block-intro">
<!--<p class="take-where-box__small-text">A Comperhensive Manual: </p>-->
</div>
<div class="take-where-box__text-block" id="take-where-box__text-block-1">
<p>How to take a dog</p>
</div>
<div class="take-where-box__text-block" id="take-where-box__text-block-2">
<p>from UK</p>
</div>
<div class="take-where-box__text-block" id="take-where-box__text-block-3">
<div class="select-box">
<div class="select-box__options-container">
<div class="select-box__option">
<input type="radio" class="radio" id="US" name="category">
<label for="US">to US</label>
</div>
<div class="select-box__option">
<input type="radio" class="radio" id="EU" name="category">
<label for="EU">to EU</label>
</div>
</div>
<!-- end of select-boxoptions-container-->
<div class="select-box__selected-option">
to US
</div>
</div>
<!-- end of select-box-->
</div>
</div>
</div>
<!-- take-where-box-->
</div>
revised codepen
i believe your code is unnecessery overcomplicated.
element positioning like in image you can achieve with this piece of code. please note that css is inline, because this is just a guidline, you can adapt it by your needs:
<div style="display:flex; align-items:center; flex-direction:column">
<div>
<div>
<p>A Comperhensive Manual:</p>
</div>
<div style="display:flex">
<p>How to take a dog from UK</p>
<p>selectbox</p>
</div>
</div>
</div>
This question already has answers here:
CSS: Width in percentage and Borders
(5 answers)
Closed 3 years ago.
I want to create a bar to go along the top of a box on a website that I am working on.
This is the desired outcome
Here's my code, I keep getting this overlap
.page {
display: flex;
flex-wrap: wrap;
position: relative;
}
.section {
border: 2px solid #FBA7FF;
width: 85%;
height: 30%;
margin: 1vw;
padding: 1vw;
display: flex;
align-items: center;
position: relative;
z-index: 1;
}
.section h1 {
position: relative;
}
.section_header {
border: 4px solid #FBA7FF;
position: absolute;
top: 0;
left: 0;
width: 100%;
bottom: 95%;
}
<div class='page'>
<div class='section'>
<div class="section_header"></div>
<h1>sample text</h1>
</div>
</div>
So far I've got the parent div with position: relative and the child element with position: absolute then setting top and left to 0 width to 100% and bottom to 95% to attempt the desired effect yet it creates an overlap.
I can see that 0 is within the div and doesn't take into account the border which is perhaps why this is happening.
* {
box-sizing: border-box;
margin: 0;
}
.page {
display: flex;
flex-wrap: wrap;
position: relative;
}
.section {
width: 100%;
display: inline-block;
text-align: center;
}
.section_header {
width: 100%;
background: #FBA7FF;
display: block;
height: 70px;
margin-bottom: 20px;
}
<div class='page'>
<div class='section'>
<div class="section_header"></div>
<h1>sample text</h1>
</div>
</div>
Remove the position:absolute and use flex-direction:column;
* {
margin: 0;
padding: 0;
}
.page {
display: flex;
flex-wrap: wrap;
flex-direction: column;
min-height: 100vh;
background: lightgrey;
position: relative;
}
.section {
border: 2px solid #FBA7FF;
width: 85%;
margin: 1vh auto;
height: 30%;
background: lightgreen;
display: flex;
flex-direction: column;
flex: 1;
align-items: center;
}
.section_header {
height: 50px;
width: 100%;
background: orange;
}
<div class='page'>
<div class='section'>
<div class="section_header"></div>
<h1>sample text</h1>
</div>
</div>
How do I get the left sidebar to overlay the content instead of pushing the content? I want it overlay on mobile but push on web layout. Flexbox is a little new to me so not sure if I need a different layout to do this or if this is possible with flexbox? I'm guessing I need to remove the sidebar from the flexbox and use a fixed relative layout ??
I'm also using angular but I removed the angular code just for simplicity so don't mind the extra divs please.
<div class="wrapper">
<header class="header">
header
</header>
<div class="main">
<div class="left-sidebar">
left sidebar
</div>
<div class="main-content-wrapper">
<div class="main-content">
<h3>Main </h3>
</div>
<footer class="footer">
<p>content</p>
<p>content</p>
<p>content</p>
</footer>
</div>
</div>
</div>
body,
html {
height: 100%;
overflow: hidden;
}
header {
min-height: 60px;
flex: none;
width: 100%;
background-color: silver;
}
.wrapper {
height: 100vh;
display: flex;
flex-direction: column;
.main {
flex: 1;
display: flex;
.main-content-wrapper {
display: flex;
flex: 1;
flex-direction: column;
overflow: auto;
.main-content {
padding: 2rem;
flex: 1;
background-color: antiquewhite;
}
footer {
background-color: silver;
min-height: 300px;
flex-shrink: 0;
}
}
}
}
.left-sidebar {
width: 0;
height: 100%;
overflow: auto;
flex: none;
&.active {
width: 250px;
}
.left-sidebar-content {
padding: 1rem;
}
}
Try this, I actually made pretty much a new structure, although not that different to yours, (did remove some elements just to work with less code); I'm using flexbox to make the whole wrapper a flex container, as well as media queries to indicate when the sidebar should push the content to the side, and when to overlap the content along with an overlay.
document.getElementById('toggleBtn').onclick = function() {
document.getElementById('sidebar').classList.toggle('active');
document.getElementById('overlay').classList.toggle('hidden');
}
document.getElementById('overlay').onclick = function() {
document.getElementById('overlay').classList.toggle('hidden');
document.getElementById('sidebar').classList.toggle('active');
}
body {
margin: 0;
}
.wrapper {
display: flex;
align-items: stretch;
height: 100vh;
}
.main-content-wrapper {
width: 100%;
}
#sidebar {
min-width: 230px;
max-width: 230px;
background-color: lightgray;
transition: all 0.3s;
height: 100vh;
margin-left: -230px;
/* top layer */
z-index: 3
}
#sidebar.active {
margin-left: 0px;
}
#media (max-width: 580px) {
#sidebar {
position: fixed;
top: 0;
/* top layer */
z-index: 3
}
.overlay {
background-color: rgba(0, 0, 0, 0.425);
width: 100vw;
height: 100vh;
z-index: 2;
top: 0;
left: 0;
position: absolute;
}
.overlay.hidden {
display: none;
}
}
<div class="wrapper">
<div class="left-sidebar" id="sidebar">
left sidebar
</div>
<div class="main-content-wrapper">
<div class="main-content">
<h3>Main </h3>
<button type="button" id="toggleBtn">Toggle</button>
</div>
</div>
<div class="overlay hidden" id="overlay"></div>
</div>
I am trying to achieve the following Layout, as per screenshot.
Main features are
Screen divided into 3 regions (columns);
Left / Right columns are fixed width;
Middle column expands as per Browser width
Right column is subdivided into two regions
Bottom region is fixed size, always at the bottom
Top region expands as per Browser height
Using HTML-tables took me about 2 hours to generate the above screenshot, with the above features.
After stuffing around with CSS for two days, I cannot get it looking as above, my attempt at CSS and associated screenshot follow below:
<html>
<head>
<title>My Layout</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
body{
height:100%;
background:beige;
}
#header {
width:100%;
height:60px;
text-align:center;
background:#A7C942;
color:#fff;
float:left;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size:2em;
}
#leftDiv {
float:left;
width:150px;
height:90%;
background:aquamarine;
}
#midDiv {
float:left;
width:auto;
height:90%;
background:lightsalmon;
display:block;
}
#rightDiv {
float:right;
width:365px;
height:90%;
background:green;
display:block;
}
#topRow {
background-color:lightgoldenrodyellow;
}
#bottomRow {
background-color:lightpink;
height:200px;
}
</style>
</head>
<body>
<div id="body">
<div id="main">
<div id="header">my header</div>
<div id="leftDiv">
<p>LEFT</p>
</div>
<div id="midDiv">
<p>MIDDLE</p>
</div>
<div id="rightDiv">
<p>RIGHT</p>
<div id="topRow">
TOP
</div>
<div id="bottomRow">
BOTTOM
</div>
</div>
</div>
</div>
</body>
</html>
Screenshot with CSS:
Problems with the CSS attempt are:
Middle col does not expand (salmon colored part);
instead white color appears out of nowhere;
cannot get pink region to stay at the bottom always
Cannot get yellow region to stretch up and down
unwanted wrapping (i.e. the right region goes under left, middle regions)
Therefore, I am about to unleash my solution using tables, unless some die-hard CSS fanatic comes to the rescue with a working answer:-)
Update
Great answers, at the time of this update there were 4. I tried out all 4 on Firefox and Chrome, and every answer is acceptable. But i can only choose one as the accepted answer, and i will go with the one that's plain and simple using only css and absolute positioning (no flexbox nor css-tables).
Thank you muchly to #matthewelsom, #Pangloss, #Shrinivas, #Paulie_D; I am sure anyone who stumbles upon your answers will find it useful for their use case. Upvotes for everyone, your efforts are appreciated!
Check out this fiddle.
It uses basic CSS and HTML and NO framework.
The key elements which allows this type of positioning are these css properties:
left, right, top, bottom.
The demo uses these properties.
Here is the snippet.
body {
background: beige;
margin: 0;
}
#header {
width: 100%;
height: 60px;
text-align: center;
background: #A7C942;
color: #fff;
font-family: "Trebuchet MS", Arial, Helvetica, sans-serif;
font-size: 2em;
}
#leftDiv {
position: absolute;
float: left;
width: 150px;
top: 60px;
bottom: 0;
background: aquamarine;
}
#midDiv {
position: absolute;
float: left;
top: 60px;
bottom: 0;
left: 150px;
right: 365px;
min-width: 50px;
background: lightsalmon;
}
#rightDiv {
position: absolute;
float: right;
width: 365px;
top: 60px;
bottom: 0;
right: 0;
background: green;
}
#topRow {
position: absolute;
width: 100%;
top: 0;
bottom: 50px;
min-height: 20px;
background-color: lightgoldenrodyellow;
}
#bottomRow {
position: absolute;
background-color: lightpink;
width: 100%;
height: 50px;
bottom: 0;
}
<div id="body">
<div id="main">
<div id="header">my header</div>
<div id="leftDiv">
<p>LEFT</p>
</div>
<div id="midDiv">
<p>MIDDLE</p>
</div>
<div id="rightDiv">
<div id="topRow">TOP</div>
<div id="bottomRow">BOTTOM</div>
</div>
</div>
</div>
Here is a quick flex layout, very rough but you'll get the idea.
You can read more about Flexbox on CSS tricks.
I have also made the design responsive so the layout will fill 100% width on screens under 480px width.
CODEPEN HERE
html, body {
height: 100%;
padding: 0;
margin: 0;
}
.wrapper {
height: 100%;
display: flex; /* NEW, Spec - Firefox, Chrome, Opera */
display: -webkit-box; /* OLD - iOS 6-, Safari 3.1-6, BB7 */
display: -ms-flexbox; /* TWEENER - IE 10 */
display: -webkit-flex; /* NEW - Safari 6.1+. iOS 7.1+, BB10 */
-webkit-flex-direction: column;
flex-direction: column;
}
.wrapper > * {
flex: 1 100%;
-webkit-flex: 1 100%;
}
.header {
flex: 1;
-webkit-flex: 1;
background: green;
width: 100%;
max-height: 80px;
}
.below {
flex: 1;
-webkit-flex: 1;
display: flex;
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
-webkit-flex-direction: row;
flex-direction: row;
}
.main {
background: deepskyblue;
flex: 3 0px;
-webkit-flex: 3 0px;
-webkit-order: 2;
order: 2;
}
.left {
background: yellow;
max-width: 100px;
flex: 1 auto;
-webkit-flex: 1 auto;
-webkit-order: 1;
order: 1;
}
.right {
background: hotpink;
max-width: 300px;
position: relative;
display: flex;
display: -webkit-box;
display: -ms-flexbox;
display: -webkit-flex;
flex: 1 auto;
-webkit-flex: 1 auto;
-webkit-order: 3;
order: 3;
-webkit-flex-direction: column;
flex-direction: column;
}
.top {
background: lightpink;
flex: 1 auto;
-webkit-flex: 1 auto;
}
.bottom {
background: salmon;
max-height: 200px;
width: 100%;
flex: 1 auto;
-webkit-flex: 1 auto;
}
#media screen and (max-width: 479px) {
.below {
-webkit-flex-direction: column;
flex-direction: column;
}
.left, .right, .main {
max-width: 100%;
flex: 1;
-webkit-flex: 1;
}
body, html, .wrapper {
height: auto;
}
}
<div class="wrapper">
<header class="header"><h3>Header</h3><p>Fixed height 80px, 100% width</p></header>
<div class="below">
<article class="main">
<h3>Flexible width Article</h3>
<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.</p>
</article>
<aside class="left">
<h3>Left</h3>
<p>100px fixed width</p>
</aside>
<aside class="right">
<div class="top">
<h3>Right Top</h3>
<p>Flexible Height, Fixed width 300px</p>
</div>
<div class="bottom">
<h3>Right Bottom</h3>
<p>Fixed width 300px, Fixed Height 200px</p>
</div>
</aside>
</div>
</div>
Here we go the CSS table layout, adjusted the markup slightly - added a couple of <div> containers for applying the styles.
JsFiddle Demo
html, body {
height: 100%;
margin: 0;
}
#page, #main, #rTable {
display: table;
border-collapse: collapse;
width :100%;
height: 100%;
}
#page > div {
display: table-row;
}
#page #hRow {
background: lightgreen;
text-align: center;
}
#page #mRow {
height: 100%;
}
#main > div {
display: table-cell;
vertical-align: top;
}
#leftDiv {
width: 100px;
background: aquamarine;
}
#midDiv {
background: lightsalmon;
}
#rightDiv {
width: 200px;
background: green;
}
#rTable > div {
display: table-row;
}
#rTable #topRow {
background: lightgoldenrodyellow;
}
#rTable #bottomRow {
height: 100px;
background: lightpink;
}
<div id="page">
<div id="hRow">
<div id="header">HEADER</div>
</div>
<div id="mRow">
<div id="main">
<div id="leftDiv">
<p>LEFT</p>
</div>
<div id="midDiv">
<p>MIDDLE</p>
</div>
<div id="rightDiv">
<div id="rTable">
<div id="topRow">RIGHT-TOP</div>
<div id="bottomRow">RIGHT-BOTTOM</div>
</div>
</div>
</div>
</div>
</div>
Using flexbox this is actually pretty simple.
Codepen Demo
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
html,
body {
min-height: 100%;
}
.wrapper {
width: 80%;
margin: auto;
display: flex;
flex-direction: column;
border: 1px solid red;
height: 100%;
}
header {
height: 50px;
background: green;
text-align: center;
line-height: 50px;
}
main {
flex-grow: 1;
border: 1px solid red;
height: 100%;
display: flex;
}
.left {
width: 200px;
background: lightblue;
flex: none;
}
.center {
flex-grow: 1;
background: salmon;
}
.right {
width: 300px;
flex:none;
background: yellow;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
}
.top {
flex-grow: 1;
background: 000;
}
.bottom {
height: 50px;
flex: none;
background: pink;
}
<div class="wrapper">
<header>
<h2>Header</h2>
</header>
<main>
<div class="col left">Fixed Left</div>
<div class="col center">Flexible Center</div>
<div class="col right">
<div class="top">Top Flexible Height inside fixed Right</div>
<div class="bottom">fixed Height Bottom</div>
</div>
</main>
</div>
CSS-Tricks.com Ultimate Guide
Prefixes will be required.
Support Reference: CanIUse.com