Reputation: 129
I was messing around on CSS grid to test things and especially grid areas and I don't succeed on doing this simple thing :
I'm trying to get the content in full width under 1500px width device. I'm pretty sure I'm missing a very simple thing, so if someone know, please feel free to help :)
https://codepen.io/N3G/pen/jOMLPMz
<div class="main-wrapper">
<div class="menu">
<ul>
<li><a href="#">Lien du menu</a></li>
<li><a href="#">Lien du menu</a></li>
<li><a href="#">Lien du menu</a></li>
<li><a href="#">Lien du menu</a></li>
</ul>
</div>
<div class="left">
Left
</div>
<main class="main">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</main>
<aside class="right">
Right
</aside>
<footer class="footer">
Footer
</footer>
</div>
*, ::before, ::after {
padding: 0;
margin: 0;
box-sizing: border-box;
}
body {
font-family: Arial;
padding: 15px;
}
.main-wrapper {
height: 100vh;
width: 100%;
display: grid;
gap: 15px;
grid-template-rows: 80px 1fr 80px;
grid-template-columns: 250px 1fr 250px;
grid-template-areas:
"menu menu menu"
"left content right"
"footer footer footer"
}
@media screen and (max-width: 1500px) {
.main-wrapper {
grid-template-rows: 1fr 250px 80px;
grid-template-columns: 250px 1fr 1fr;
grid-template-areas:
"menu content content"
"menu left right"
"footer footer footer"
}
}
.menu {
grid-area: menu;
background: grey;
}
.menu ul {
display: flex;
justify-content: space-between;
max-width: 800px;
margin: 0 auto;
}
@media screen and (max-width: 1500px) {
.menu ul {
flex-direction: column
}
}
.main-wrapper > * {
padding: 15px;
border: 1px solid #999;
}
.left {
grid-area: left;
background: #ccc
}
.right {
grid-area: right;
background: #ccc
}
.content {
grid-area: content
}
.footer {
grid-area: footer;
background: darkgrey
}
Thanks guys.
Upvotes: 0
Views: 210
Reputation: 178
In your HTML the section that you have called 'main' change the class to content instead of main.
<main class="content">
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
</main>
You do not have a class named main in your CSS.
Upvotes: 1
Reputation: 114991
You have an incorrect selector which does not match your HTML
.content {
grid-area: content
}
should be
.main {
grid-area: content
}
Upvotes: 1