Goal:
Make the content to have fixed width 700px in desktop only and the left-content and right-content width should adapt to desktop's width.
Problem:
I don't know how to solve it in a good way.
Info:
*The layout needs to take account to responsive design.
*Desktop width size start att min-width 901px
*Stil newbie in css layout
Jsbin:
https://jsbin.com/wegebemoqe/edit?html,css,output
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta charset="UTF-8" />
</head>
<body>
<div id="container">
<div id="top-content" class="palette-1">
top
</div>
<div id="content" class="palette-2">
content
</div>
<div id="footer" class="palette-4">
footer
</div>
<div id="left-content" class="palette-5">
</div>
<div id="right-content" class="palette-5">
</div>
</div>
</body>
</html>
body {
color: white;
text-align: center;
box-sizing: content-box;
margin: 20px;
}
.palette-1 {
background-color: #83B2FF;
}
.palette-2 {
background-color: #8BF18B;
}
.palette-4 {
background-color: #FF8650;
}
.palette-5 {
background-color: #FF555E;
}
#container {
margin: 2.5rem;
padding: 0.625rem;
background-color: #FFE981;
height: 37.5rem;
width: calc(100vw - 10rem);
display: grid;
grid-template-areas:
"header header header header"
"left-content content content right-content"
"footer footer footer footer";
row-gap: 1rem;
}
@media screen and (min-width: 901px) {
#content {
width: 700px;
}
}
@media screen and (max-width: 900px) {
#container {
grid-template-areas:
"header header"
"content content"
"footer footer"
}
#left-content, #right-content {
display: none;
}
}
.item {
padding: 1.5rem;
}
#top-content {
grid-area: header;
}
#content {
grid-area: content;
}
#footer {
grid-area: footer;
}