I'm trying to learn about grid-template-areas
.
But my code is not working like the intended area template:
"title title"
"both-a both-b"
"left-a right-a"
"left-b right-b"
All left items should be to the left of the corresponding ("a" or "b") right items.
* {
border: 1px solid black;
}
.wrapper {
display: grid;
grid-template-areas: "title title"
"both-a both-b"
"left-a right-a"
"left-b right-b";
}
.wrapper > header {
grid-area: title;
}
.both > .topic-a {
grid-area: both-a;
}
.both > .topic-b {
grid-area: both-b;
}
.left > .topic-a {
grid-area: left-a;
}
.left > .topic-b {
grid-area: left-b;
}
.right > .topic-a {
grid-area: right-a;
}
.right > .topic-b {
grid-area: right-b;
}
.left-side {
color: red;
}
.right-side {
color: blue;
}
<article class="wrapper">
<header><h1>Title</h1></header>
<section class="both">
<section class="topic-a">
<ol>
<li>both-A 1st item</li>
<li>2nd item</li>
<li>3rd item</li>
</ol>
</section>
<section class="topic-b">
<ol>
<li>both-B 1st item</li>
<li>2nd item</li>
<li>3rd item</li>
</ol>
</section>
</section>
<section class="left-side">
<section class="topic-a">
<ol>
<li>left-A 1st item</li>
<li>2nd item</li>
<li>3rd item</li>
<li>nth item</li>
<li>nth item</li>
<li>nth item</li>
<li>nth item</li>
<li>nth item</li>
</ol>
</section>
<section class="topic-b">
<ol>
<li>left-B 1st item</li>
<li>2nd item</li>
<li>3rd item</li>
</ol>
</section>
</section>
<section class="right-side">
<section class="topic-a">
<ol>
<li>right-A 1st item</li>
<li>2nd item</li>
<li>3rd item</li>
</ol>
</section>
<section class="topic-b">
<ol>
<li>right-B 1st item</li>
<li>2nd item</li>
<li>3rd item</li>
<li>nth item</li>
<li>nth item</li>
<li>nth item</li>
<li>nth item</li>
<li>nth item</li>
</ol>
</section>
</section>
</article>
I know it's probably a silly mistake, but I can't figure it out.
left-side
andright-side
, to make left-a be on the left side of right-a – Centroid