I have made this CSS grid. I am still practising using the CSS grid, so I am trying to imitate this site. I would like to place the text the same place as the template I link to.
But how is the correct way to do this? At the moment the link is in the upper left corner.
Should I make another div inside the first div tag, or what is the best way to do it?
Best regards.
.wrapper {
display:grid;
grid-template-columns:repeat(12,1fr);
grid-gap: 10px;
}
.wrapper > div {
background-color: #eee;
padding: 1em;
box-sizing: border-box;
}
.wrapper > div:nth-child(odd) {
background-color: #ddd;
}
.item1 {
grid-row: 1 / 3;
grid-column: 1/7;
height: 700px;
}
.item2 {
grid-row: 1 / 1;
grid-column: 7/13;
height: 340px;
}
.item3 {
grid-row: 2 / 3;
grid-column: 7/10;
height: 350px;
}
.item4 {
grid-row:2/3;
grid-column: 10/13;
height: 350px;
}
a {
font-size: 30px;
}
@media only screen and (max-width: 600px) {
.wrapper {
display:grid;
grid-template-columns:repeat(12,1fr);
grid-gap: 10px;
}
.item1 {
grid-row: 1 / 3;
grid-column: 1/13;
height: 350px;
}
.item2 {
grid-row: 3 / 3;
grid-column: 1/13;
height: 200px;
}
.item3 {
grid-row: 4 / 5;
grid-column: 1 / 7;
height: 200px;
}
.item4 {
grid-row: 4 / 5;
grid-column: 7 / 13;
height: 200px;
}
}
/*
.nested {
display:grid;
grid-template-columns:repeat(3,1fr);
grid-gap:1em;
}
.nested > div {
border:1px solid red;
grid-auto-rows: 70px;
padding:1em;
}
*/
<div class="wrapper">
<div class="item1">
<a href="#">Watch a tiny cat taking a bath</a>
</div>
<div class="item2">
<a href="#">Spain: Take a virtual tour</a>
</div>
<div class="item3">
<a href="#">5 Tips to create your garden</a>
</div>
<div class="item4">
<a href="#">10 Movies you need to see</a>
</div>
</div>