CSS grid - two columns on desktop and 1 column on mobile - css

This is what I want to achieve:
On desktop/big screen - 30% of the left side and around 70% of the right side
On mobile/smaller screens - right side goes on top of the left side
Here's what I have so far. I have a feeling I'm using the grid in the right or at least I'm not achieving what I have above...
body {
margin: 40px;
}
.sidebar {
grid-area: sidebar;
}
.content {
grid-area: content;
}
.wrapper {
display: grid;
grid-gap: 10px;
grid-template-columns: auto;
grid-template-areas: "sidebar content content content";
background-color: #fff;
color: #444;
}
.box {
background-color: #444;
color: #fff;
border-radius: 5px;
padding: 20px;
font-size: 150%;
}
.header {
background-color: #999;
}
#media (max-width: 768px) {
grid-template-rows: repeat(auto, 1fr);
grid-template-areas:
"content"
"sidebar";
}
<div class="wrapper">
<div class="box sidebar">Sidebar</div>
<div class="box content">Content</div>
</div>
What's the best approach to this?

You forget to wrap css in .wrapper class in media query
body {
margin: 40px;
}
.sidebar {
grid-area: sidebar;
}
.content {
grid-area: content;
}
.wrapper {
display: grid;
grid-gap: 10px;
grid-template-columns: auto;
grid-template-areas: "sidebar content content content";
background-color: #fff;
color: #444;
}
.box {
background-color: #444;
color: #fff;
border-radius: 5px;
padding: 20px;
font-size: 150%;
}
.header {
background-color: #999;
}
#media (max-width: 768px) {
.wrapper {
grid-template-rows: repeat(auto, 1fr);
grid-template-areas:
"content"
"sidebar";
}
}
<div class="wrapper">
<div class="box sidebar">Sidebar</div>
<div class="box content">Content</div>
</div>
jsfiddle link

body {
margin: 40px;
}
.sidebar {
grid-area: sidebar;
}
.content {
grid-area: content;
width: 70%
}
.wrapper {
display: grid;
display: flex;
flex-wrap: wrap;
grid-gap: 10px;
grid-template-columns: auto;
grid-template-areas: "sidebar content content content";
background-color: #fff;
color: #444;
}
.box {
background-color: #444;
color: #fff;
border-radius: 5px;
padding: 20px;
font-size: 150%;
}
.header {
background-color: #999;
}
#media (max-width: 768px) {
grid-template-rows: repeat(auto, 1fr);
grid-template-areas:
"content"
"sidebar";
}
#media (max-width: 625px) {
.content {
width: 100%;
}
.sidebar {
width: 100%;
}
}
<div class="wrapper">
<div class="box sidebar">Sidebar</div>
<div class="box content">Content</div>
</div>
First i used flex-wrap to toggle between row and column as per the width of the screen. Then i used media query to change the width of the elements as you want different widths in row and column view.

Related

Positioning an element between two elements if there is room, but below if necessary

I would like to center my post title between two navigation buttons.
On small screens, I want the navigation buttons to be together at the top, and for the title to wrap below.
Desired result on large screens:
Desired result on small screens:
The post title, date, and tags are contained in one flex-grow div.
#post-head {
display: flex;
flex-direction: column;
align-items: stretch;
position: relative;
background-color: #col-3-1;
margin-left: -1vw;
margin-right: -1vw;
}
#post-meta {
display: flex;
flex-direction: column;
flex-grow: 1;
align-items: center;
font-family: maven;
font-weight: 700;
// background: linear-gradient(lighten(#col-3-1, 10) 0%, #col-3-1 20%);
}
#post-title {
font-size: 40px;
margin-top: 10px;
color: white;
}
#post-date {
font-size: 24px;
color: fade(white, 80);
}
#post-tags {
padding: 15px;
font-weight: 300;
}
#post-tags>div {
display: inline-block;
padding: 3px 12px 3px 12px;
background-color: fade(black, 20);
border-radius: 15px;
border: 1px solid fade(white, 20);
}
#post-nav {
display: flex;
justify-content: space-between;
}
#post-nav>div {
display: inline-block;
text-align: center;
background-color: rgba(0, 0, 0, 0.5);
border: 1px solid white;
padding: 10px;
margin-left: 20px;
margin-right: 20px;
min-width: 120px;
}
<div id="post-head">
<div id="post-nav">
<div>
< Previous Post</div>
<div>Next Post ></div>
</div>
<div id="post-meta">
<div id="post-title">Post Title</div>
<div id="post-date">12 July, 2022</div>
<div id="post-tags">
<div>Tag 1</div>
<div>Tag 2</div>
</div>
</div>
</div>
</div>
I had to adjust quite a lot - both HTML and CSS - to make it work the way you want so I suggest you dig into the details.
Essential is the use of a media query to separate small screen styles from large screen styles an the order property for flex items. You can find more about media queries here
#post-head {
display: flex;
align-items: stretch;
position: relative;
background-color: #col-3-1;
margin-left: -1vw;
margin-right: -1vw;
flex-wrap: wrap;
}
#post-meta {
display: flex;
flex-direction: column;
flex-grow: 1;
align-items: center;
font-family: maven;
font-weight: 700;
width: 100vw;
}
#post-title {
font-size: 40px;
margin-top: 10px;
}
#post-date {
font-size: 24px;
color: fade(white, 80);
}
#post-tags {
padding: 15px;
font-weight: 300;
}
#post-tags>div {
display: inline-block;
padding: 3px 12px 3px 12px;
background-color: fade(black, 20);
border-radius: 15px;
border: 1px solid fade(white, 20);
}
#post-head {
display: flex;
justify-content: space-between;
}
#post-head>div:nth-child(1),
#post-head>div:nth-child(2) {
display: flex;
background-color: rgba(0, 0, 0, 0.5);
border: 1px solid white;
padding: 10px;
margin-left: 20px;
margin-right: 20px;
min-width: 120px;
width: 120px;
max-height: 30px;
justify-content: center;
align-items: center;
}
#media (min-width: 900px) {
#post-meta {
width: initial;
}
#post-head {
flex-wrap: no-wrap;
}
#post-previous {
order: 1;
}
#post-next {
order: 3;
}
#post-meta {
order: 2;
}
}
<div id="post-head">
<div id="post-previous">< Previous Post</div>
<div id="post-next">Next Post ></div>
<div id="post-meta">
<div id="post-title">Post Title</div>
<div id="post-date">12 July, 2022</div>
<div id="post-tags">
<div>Tag 1</div>
<div>Tag 2</div>
</div>
</div>
</div>
I have done by using CSS Grid.
body{
background-color:#42243C;
color:white;
}
#post-nav{
display:grid;
grid-template-columns:1fr 1fr 1fr;
grid-template-rows:1fr 2fr;
text-align:center;
}
.prev, .next{
text-align:center;
border:1px solid black;
}
.prev{
margin-left:20px;
}
.next{
margin-right:20px;
}
#post-tags{
display:grid;
grid-template-columns:1fr 1fr;
grid-gap:5px;
}
.t1{
text-align:right;
}
.t2{
text-align:left;
}
#media only screen and (max-width: 650px) {
#post-meta{
grid-row:2/3;
grid-column:1/3;
}
#post-nav{
display:grid;
grid-template-columns:1fr 1fr;
text-align:center;
justify-self:center;
grid-column-gap:20px;
grid-row-gap:10px;
}
}
<div id="post-head">
<div id="post-nav">
<div class="prev"> < Previous Post</div>
<div id="post-meta">
<div id="post-title">Post Title</div>
<div id="post-date">12 July, 2022</div>
<div id="post-tags">
<div class="t1">Tag 1</div>
<div class="t2">Tag 2</div>
</div>
</div>
<div class="next">Next Post ></div>
</div>
</div>
Between the helpful answers given by Arman and Gerard, I was able to get what I want!
I think a grid layout is definitely the better option here. The key was to set the grid-template-rows property to auto 0fr to prevent extra space being reserved in the grid. Also, I increased the number of columns so that it can be evenly divided when the navigation buttons are put on a new row.
#post-head{
display:grid;
grid-template-columns:1fr 1fr 1fr 1fr;
grid-template-rows:auto 0fr;
text-align:center;
}
.post-nav.prev{
grid-column:1/2;
}
.post-nav.next{
grid-column:4/5;
}
#post-meta{
grid-row: 1/2;
grid-column:2/4;
}
#media only screen and (max-width: 650px) {
#post-meta{
grid-row:2/3;
grid-column: 1/5;
}
.post-nav.prev{
grid-column:1/3;
}
.post-nav.next{
grid-column:3/5;
}
}
<div id="post-head">
<div class="post-nav prev">< Previous Post</div>
<div id="post-meta">
<div id="post-title">Post Title</div>
<div id="post-date">12 July, 2022</div>
</div>
<div class="post-nav next">Next Post ></div>
</div>

Make list items inside CSS Grid item stay in the center vertically aligned even when resizing viewport width

Hello everyone and a big thank you to everyone who tries to help us newcomers to code.
I am trying to vertically align my list items inside the navbar/grid item.
As you can see, the logo on the left stays there nicely vertically in the middle even if I resize the viewport. But the navigation buttons don't.
The logo and the list items belong to the same grid item.
they are both inline
they have the same identical instructions set to them
I would put everything inside a pen, but you can't see it there, you can only see it with inspect element and 50% zoom.
What am I missing?
Thank you!
* {
padding: 0;
box-sizing: border-box;
border-radius: 5px;
text-align: center;
}
body {
background: #F7DAD4;
}
.grid {
display: grid;
height: 98vh;
grid-template-columns: 1fr 4fr 1fr;
grid-template-rows: 0.5fr 1fr 3.5fr 1fr;
grid-gap: 2vh;
grid-template-areas: "nav nav nav" "header header header" "left main right" "footer footer footer";
}
nav {
background: #0A3409;
color: #F7DAD4;
grid-area: nav;
position: relative;
}
.logo {
float: left;
position: relative;
left: 10vw;
top: 50%;
transform: translate(0, -50%);
}
.logo a {
color: #F7DAD4;
text-decoration: none;
font-family: arial black;
font-size: 2em;
}
ul {
float: right;
list-style: none;
}
ul li {
position: relative;
display: inline;
right: 10vw;
top: 50%;
transform: translate(0, -50%);
border: 1px solid white;
}
li a {
text-decoration: none;
color: #F7DAD4;
font-family: arial;
font-weight: bold;
font-size: 1.5em;
transition: 0.2s;
border-radius: initial;
padding: 0 20px;
}
li a:hover {
color: #0A3409;
background-color: #F7DAD4;
}
header {
background: #0A3409;
color: #F7DAD4;
grid-area: header;
}
.left {
background: #FD3A0F;
color: #F7DAD4;
grid-area: left;
}
main {
background: #559E54;
color: #0A3409;
grid-area: main;
}
.right {
background: #17B814;
color: #F7DAD4;
grid-area: right;
}
footer {
background: #0A3409;
color: #F7DAD4;
grid-area: footer;
}
#media only screen and (max-width: 768px) {
.grid {
grid-template-columns: 3fr 2fr;
grid-template-rows: 0.5fr 1fr 1.75fr 1.75fr 1fr;
grid-template-areas: "nav nav" "header header" "main left" "main right" "footer footer";
}
}
#media only screen and (max-width: 500px) {
.grid {
grid-template-columns: 1fr;
grid-template-rows: 0.5fr 1fr 3.5fr 1fr 1fr 1fr;
grid-template-areas: "nav" "header" "main" "left" "right" "footer";
}
}
<div class="grid">
<nav>
<div class="logo">
danctes
</div>
<ul>
<li>Funny</li>
<li>Relatable</li>
<li>Dark</li>
<li>Latest</li>
<li>Best</li>
</ul>
</nav>
<header>Header</header>
<div class="left">Left</div>
<main>Main</main>
<div class="right">Right</div>
<footer>Footer</footer>
</div>
Consider using Flexbox instead of transforms and float when positioning UI elements, I commented out the changes in the code, it should be easy for you read through
* {
margin:0; /* New */
padding: 0;
box-sizing: border-box;
border-radius: 5px;
text-align: center;
}
body {
background: #F7DAD4;
}
.grid {
display: grid;
height: 98vh;
grid-template-columns: 1fr 4fr 1fr;
grid-template-rows: 0.5fr 1fr 3.5fr 1fr;
grid-gap: 2vh;
grid-template-areas: "nav nav nav" "header header header" "left main right" "footer footer footer";
}
nav {
background: #0A3409;
color: #F7DAD4;
grid-area: nav;
position: relative;
/* NEW */
display: flex;
height: 100%;
}
.logo {
/* NEW */
display: flex;
height: 100%;
align-items: center;
/* Removed
/* float: left;
/* position: relative;
/* left: 10vw;
/* top: 50%;
/* transform: translate(0, -50%); */
}
.logo a {
color: #F7DAD4;
text-decoration: none;
font-family: arial black;
font-size: 2em;
}
ul {
list-style: none;
/* NEW */
display: flex;
margin-left: auto;
height: 100%;
align-items: center;
/* Removed
/* float: right; */
}
ul li {
border: 1px solid white;
/* Removed
/* position: relative; */
/* display: inline; */
/* right: 10vw; */
/* top: 50%; */
/* transform: translate(0, -50%); */
}
li a {
text-decoration: none;
color: #F7DAD4;
font-family: arial;
font-weight: bold;
font-size: 1.5em;
transition: 0.2s;
border-radius: initial;
padding: 0 20px;
}
li a:hover {
color: #0A3409;
background-color: #F7DAD4;
}
header {
background: #0A3409;
color: #F7DAD4;
grid-area: header;
}
.left {
background: #FD3A0F;
color: #F7DAD4;
grid-area: left;
}
main {
background: #559E54;
color: #0A3409;
grid-area: main;
}
.right {
background: #17B814;
color: #F7DAD4;
grid-area: right;
}
footer {
background: #0A3409;
color: #F7DAD4;
grid-area: footer;
}
#media only screen and (max-width: 768px) {
.grid {
grid-template-columns: 3fr 2fr;
grid-template-rows: 0.5fr 1fr 1.75fr 1.75fr 1fr;
grid-template-areas: "nav nav" "header header" "main left" "main right" "footer footer";
}
}
#media only screen and (max-width: 500px) {
.grid {
grid-template-columns: 1fr;
grid-template-rows: 0.5fr 1fr 3.5fr 1fr 1fr 1fr;
grid-template-areas: "nav" "header" "main" "left" "right" "footer";
}
}
<div class="grid">
<nav>
<div class="logo">
danctes
</div>
<ul>
<li>Funny</li>
<li>Relatable</li>
<li>Dark</li>
<li>Latest</li>
<li>Best</li>
</ul>
</nav>
<header>Header</header>
<div class="left">Left</div>
<main>Main</main>
<div class="right">Right</div>
<footer>Footer</footer>
</div>

Grid gap being added causes row items to overflow grid container but not column items [duplicate]

This question already has answers here:
The difference between percentage and fr units
(3 answers)
Closed 1 year ago.
I've come across an example of grid layout and don't understand why adding grid gap to rows and columns causes the row items to overflow the container (which I understand) but not the column items; instead the container expands with no overflow.
body {
padding: 20px;
}
.grid-container {
border: 5px solid black;
font-family: avenir, sans-serif;
font-weight: bold;
display: grid;
grid-template-columns: repeat(4, 25%);
grid-template-rows: 100px 100px;
gap: 20px;
}
.grid-item {
padding: 10px 20px;
}
.grid-item:nth-child(1) {
background: darkcyan;
}
.grid-item:nth-child(2) {
background: turquoise;
}
.grid-item:nth-child(3) {
background: aquamarine;
}
.grid-item:nth-child(4) {
background: lightgreen;
}
.grid-item:nth-child(5) {
background: mediumseagreen;
}
<div class="grid-container">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
<div class="grid-item">5</div>
</div>
You should use fr units for that kind of use in grid-template-columns: repeat(4, 1fr);
1fr represent 1 fraction of the available space
body {
padding: 20px;
}
.grid-container {
border: 5px solid black;
font-family: avenir, sans-serif;
font-weight: bold;
display: grid;
grid-template-columns: repeat(4, 1fr);
grid-template-rows: 100px 100px;
grid-gap: 20px;
}
.grid-item {
padding: 10px 20px;
}
.grid-item:nth-child(1) {
background: darkcyan;
}
.grid-item:nth-child(2) {
background: turquoise;
}
.grid-item:nth-child(3) {
background: aquamarine;
}
.grid-item:nth-child(4) {
background: lightgreen;
}
.grid-item:nth-child(5) {
background: mediumseagreen;
}
<div class="grid-container">
<div class="grid-item">1</div>
<div class="grid-item">2</div>
<div class="grid-item">3</div>
<div class="grid-item">4</div>
<div class="grid-item">5</div>
</div>

Grid template with an inner overflow-x element break layout in chrome but not in firefox [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I’m having issues tracking the problem of a div that contains a big table (a green div in the fiddle). I want this div to have a working overflow-x: auto.
On firefox I don’t see any issues, the table container when the windows is too little adds a scrollbar, with chrome or opera the browser scrollbar is shown alongside the block scrollbar, and the page content extends over the window length.
If I don’t use Grid, all browsers show the same behavior, with a scrollbar only in the parent block of the table.
Here's a fiddle and snippet:
.content {
grid-area: content;
display: block;
max-width: 1200px;
margin: 0 auto;
width: 100%;
box-sizing: border-box;
min-height: calc(100vh - 6em);
overflow: hidden;
}
.footer {
grid-area: footer;
height: 3em;
background-color: grey;
}
.sidemenu {
height: 3em;
grid-area: sidemenu;
background-color: grey;
}
.wrapper {
display: grid;
grid-template-areas:
"sidemenu"
"content"
"footer";
}
.big {
background-color: green;
width: 2980px;
height: 20px;
}
.blockWrapper { overflow-x: auto; }
#media (min-width: 500px) {
.wrapper {
grid-template-columns: 3em 1fr;
grid-template-areas:
"sidemenu content"
"sidemenu footer";
}
.sidemenu { height: 100%; }
}
<div class="wrapper">
<div class="sidemenu"></div>
<div class="content">
<div class="blockWrapper">
<div class="big"></div>
</div>
</div>
<div class="footer"></div>
</div>
You can remove width: 100% and margin: 0 auto on .content to get the same behavior in Chrome & Firefox - see demo below:
.content {
grid-area: content;
display: block;
max-width: 1200px;
/*margin: 0 auto;
width: 100%;*/
box-sizing: border-box;
min-height: calc(100vh - 6em);
overflow: hidden;
}
.footer {
grid-area: footer;
height: 3em;
background-color: grey;
}
.sidemenu {
height: 3em;
grid-area: sidemenu;
background-color: grey;
}
.wrapper {
display: grid;
grid-template-areas: "sidemenu" "content" "footer";
}
.big {
background-color: green;
width: 2980px;
height: 20px;
}
.blockWrapper {
overflow-x: auto;
}
#media (min-width: 500px) {
.wrapper {
grid-template-columns: 3em 1fr;
grid-template-areas: "sidemenu content" "sidemenu footer";
}
.sidemenu {
height: 100%;
}
}
<div class="wrapper">
<div class="sidemenu"></div>
<div class="content">
<div class="blockWrapper">
<div class="big"></div>
</div>
</div>
<div class="footer"></div>
</div>
Another fix can be to specify grid-template-columns: 100% and grid-template-columns: 3em calc(100% - 3em) for the media query above 500px - see demo below:
.content {
grid-area: content;
display: block;
max-width: 1200px;
margin: 0 auto;
width: 100%;
box-sizing: border-box;
min-height: calc(100vh - 6em);
overflow: hidden;
}
.footer {
grid-area: footer;
height: 3em;
background-color: grey;
}
.sidemenu {
height: 3em;
grid-area: sidemenu;
background-color: grey;
}
.wrapper {
display: grid;
grid-template-areas: "sidemenu" "content" "footer";
grid-template-columns: 100%; /* added */
}
.big {
background-color: green;
width: 2980px;
height: 20px;
}
.blockWrapper {
overflow-x: auto;
}
#media (min-width: 500px) {
.wrapper {
grid-template-columns: 3em 1fr;
grid-template-areas: "sidemenu content" "sidemenu footer";
grid-template-columns: 3em calc(100% - 3em); /* added */
}
.sidemenu {
height: 100%;
}
}
<div class="wrapper">
<div class="sidemenu"></div>
<div class="content">
<div class="blockWrapper">
<div class="big"></div>
</div>
</div>
<div class="footer"></div>
</div>

flex setting items below each other [duplicate]

This question already has answers here:
Is it possible for flex items to align tightly to the items above them?
(5 answers)
Closed 4 years ago.
i'm trying to get to the layout from middle to left as shown in the picture.
How can i make the grey div to push itself up using flex? Should i just use fixed position for it? Thought about changing the html to create container div for the orange and grey boxes, but I want to see how to do it without changing the html.
#import 'general.css';
#import 'reg.css';
#import "768.css" screen and (min-width : 992px);
#import "992.css" screen and (min-width : 1200px);
/*general*/
body, html{
margin: 0;
padding:0;
height: 100%;
}
* {
box-sizing: border-box;
}
/*reg*/
.container{
background-color: red;
text-align: center;
display: flex;
height: 100%;
flex-wrap: wrap;
}
.box{
height: 10%;
width: 100%;
}
header{
background-color: black;
color: white;
width: 100%;
order:1;
}
footer{
background-color: navy;
color: white;
width: 100%;
order:5;
}
.main-content{
background-color: dodgerblue;
height: 60%;
width: 100%;
order:2;
}
.grey{
background-color: grey;
order:4;
}
.orange{
background-color: orangered;
order:3;
}
/*768*/
.box{
height: 11%;
}
.main-content{
height: 67%;
}
.grey{
width: 30%;
order:3;
}
.orange{
background-color: orangered;
width: 70%;
order:4;
}
/*992*/
.main-content{
width: 85%;
order:3;
align-self: flex-end;
height: 80%;
}
.grey{
width: 15%;
order:4;
align-self: flex-start;
height:20% ;
}
.orange{
width:15%;
order:2;
align-self: flex-start;
height: 60%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="css/index.css">
<title>Document</title>
</head>
<body>
<div class="container">
<header class="box">this is the header</header>
<div class="main-content box">this is main content</div>
<div class="orange box">this is the orange</div>
<div class="grey box">this is the grey</div>
<footer class="box">this is the footer</footer>
</div>
</body>
</html>
I don’t see any solution only using flex because boxes will flow in lines. So as you mentioned, using a positioning for the grey box would be the only way to achieve this.
This is a solution using grid though:
body, html {
height: 100%;
padding:0;
margin: 0;
}
* {
box-sizing: border-box;
}
.container {
display: grid;
grid-template-areas:
"a"
"b"
"c"
"d"
"e";
grid-template-rows: 1fr 60% 1fr 1fr 1fr;
height: 100%;
background-color: red;
}
.box {
display: flex;
justify-content: center;
align-items: center;
}
header {
grid-area: a;
color: white;
background-color: black;
}
.main-content {
grid-area: b;
background-color: dodgerblue;
}
.orange {
grid-area: c;
order: 4;
background-color: orangered;
}
.grey {
grid-area: d;
background-color: grey;
}
footer {
grid-area: e;
color: white;
background-color: navy;
}
#media ( min-width: 768px ) {
.container {
grid-template-areas:
"a a"
"b b"
"d c"
"e e";
grid-template-rows: 15% 4fr 1fr 15%;
grid-template-columns: 15% 1fr;
}
#media ( min-width: 992px ) {
.container {
grid-template-areas:
"a a"
"c b"
"d b"
"e e";
grid-template-rows: 15% 4fr 1fr 15%;
grid-template-columns: 15% 1fr;
}
}
<div class="container">
<header class="box">this is the header</header>
<div class="box main-content">this is main content</div>
<div class="box orange">this is the orange</div>
<div class="box grey">this is the grey</div>
<footer class="box">this is the footer</footer>
</div>
You can use the order style of flex children to affect what order they are rendered inside of a flex parent, however this does require some wrapping divs so you'd have to change your HTML slightly, otherwise you must use CSS grid. Snippet with working example of your images below:
:root {
--min-height: 80px;
}
* {
border-sizing: border-box;
padding: 0;
margin: 0;
}
html, body, .container {
height: 100%;
}
body {
padding: 10px;
}
div {
border-radius: 10px;
}
.container {
display: flex;
flex-direction: column;
}
.container > div {
margin-bottom: 10px;
}
.container > div:last-child {
margin: 0;
}
.main-content > div {
margin-bottom: 10px;
}
.main-content > div:last-child {
margin: 0;
}
.side-content > div {
margin-bottom: 10px;
}
.side-content > div:last-child {
margin: 0;
}
.header, .footer, .content {
min-height: var(--min-height);
}
.teal.content {
min-height: calc(5 * var(--min-height));
}
.black {
background: rgb(30, 32, 42);
}
.teal {
background: rgb(74, 161, 162);
}
.orange {
background: rgb(253, 170, 82);
}
.gray {
background: rgb(203, 187, 172);
}
.navy {
background: rgb(61, 94, 109);
}
#media screen and (min-width: 768px) {
.side-content {
display: flex;
flex-direction: row;
}
.side-content > div {
margin: 0;
}
.side-content > div:last-child {
margin-right: 10px;
}
.orange {
flex: 2 0 auto;
order: 1;
}
.gray {
flex: 1 0 auto;
order: 0;
}
}
#media screen and (min-width: 992px) {
.main-content {
display: flex;
flex-direction: row;
}
.main-content > div {
margin: 0;
}
.main-content > div:last-child {
margin-right: 10px;
}
.side-content {
order: 0;
flex: 1 0 auto;
flex-direction: column;
margin-right: 10px;
}
.side-content > div:last-child {
margin: 0;
}
.side-content > div:first-child {
margin-bottom: 10px;
}
.orange {
order: 0;
margin-bottom: 10px;
}
.teal {
order: 1;
flex: 7 0 auto;
}
}
<div class="container">
<div class="black header"></div>
<div class="main-content">
<div class="teal content"></div>
<div class="side-content">
<div class="orange content"></div>
<div class="gray content"></div>
</div>
</div>
<div class="navy footer"></div>
</div>

Resources