Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLoes Kockelmans
Courses Plus Student 6,715 Pointsgrid-template-areas doesn't work
Ive been working on creating a grid via grid-template-areas but for some reason it doesn't work and I can't figure out why, I've done multiple google searches for it. I hope someone can help me.
My HTML is: <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <html lang="en-US"> <meta name="description" content="Voorbeeld van Plusport website"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>PlusPort</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="wrapper"> <nav>navigation</nav> <header>header</header> <main>main</main> <aside>side</aside> <footer>footer</footer> </div> </body> </html>
my css is:
.wrapper{
height: 100vh;
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
grid-column-gap: 10px;
grid-template-areas:
"nav nav nav nav"
"header header header header"
"main main side side"
"main main main main"
"footer footer footer footer";
}
nav{ grid-area: nav; background-color: green; color: yellow; } header{ grid-area: header; background-color: red; } main{ grid-area: main; background-color: blue; } aside{ grid-area: side; background-color: grey; } footer{ grid-area: footer; background-color: green; color: white; }
chrome developerstool gives me an error one the line in which I declare my grid-template-areas and tells me I have an invalid property value. I've tried al kinds of variations but none work.
1 Answer
Loes Kockelmans
Courses Plus Student 6,715 PointsThank you so much for your answer! I was just playing around with the grid items, so I will rethink how to actually build the site I'm working on. Thanx again!
hayden carnegie
601 Pointshayden carnegie
601 PointsHi,
Your issue is down to your Grid Template Areas:
You can't have a grid area that isn't a perfect square/rectangle. If you adjust it too
That will fix your issue.
You might want to rethink how you will do your build of the sidebar so that the main area will wrap around your sidebar.