Tell us what’s happening:
Please guys take a second look at my code, it didn’t pass. These are the error messages I got:
12. The display
property of the .newspaper-layout
element should be set to grid
.
-
Failed:13. Your
.newspaper-layout
element should have agrid-template-areas
property withtitle
spanning all three columns of the first row. -
Failed:14. The second row of the grid template should contain a
feature-article
spanning two columns and acover-image
. -
Failed:15. The third row of the grid template should contain a
secondary-article
spanning two columns and acover-image
. -
Failed:16. The fourth row of the grid template should contain
small-article1
,small-article2
, andsmall-article3
. -
Failed:17. Your
.newspaper-layout
selector should use thegrid-template-columns
property to divide the space into three equal parts. Remember you can use either therepeat
function or manually define each fractional unit. -
Failed:18. Your
.newspaper-layout
selector should have agrid-template-rows
property set toauto 1fr 1fr 1fr
. -
Failed:19. You should add a gap between grid items.
-
Failed:20.
.title
should have agrid-area
oftitle
. -
Failed:21.
.feature-article
should have agrid-area
offeature-article
. -
Failed:22.
.cover-image
should have agrid-area
ofcover-image
. -
Failed:23.
.secondary-article
should have agrid-area
ofsecondary-article
. -
Failed:24.
.small-article1
should have agrid-area
ofsmall-article1
. -
Failed:25.
.small-article2
should have agrid-area
ofsmall-article2
. -
Failed:26.
.small-article3
should have agrid-area
ofsmall-article3
. -
Failed:27. The
img
inside.cover-image
should have amax-width
of100%
.
Your code so far
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>CSS Grid Newspaper</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
<main class="newspaper-layout">
<header class="title">
<h1>The Daily Grid Times</h1>
</header>
<article class="feature-article">
<h2>Breaking News: CSS Grid Shapes the Future</h2>
<p>CSS Grid is revolutionizing web layouts, making it easier to design
complex, responsive structures without messy hacks.</p>
</article>
<figure class="cover-image">
<img src="https://via.placeholder.com/300x300" alt="Cover image"/>
</figure>
<article class="secondary-article">
<h2>Developers Celebrate Grid Layout</h2>
<p>Web developers worldwide are adopting CSS Grid to streamline
their workflow and create more dynamic, user-friendly designs.</p>
</article>
<article class="small-article1">
<h3>Sub Article One</h3>
<p>A quick look at how grid-template-areas simplifies layouts.</p>
</article>
<article class="small-article2">
<h3>Sub Article Two</h3>
<p>Tips and tricks for mastering CSS Grid in no time.</p>
</article>
<article class="small-article3">
<h3>Sub Article Three</h3>
<p>Why grids are better than floats and flexbox in certain cases.</p>
</article>
</main>
</body>
</html>
/* file: styles.css */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
}
.newspaper-layout {
display: grid;
grid-template-columns: repeat(3, 1fr);
grid-template-rows: auto 1fr 1fr 1fr;
grid-template-areas: "title title title"
"feature-article feature-article cover-image"
"secondary-article secondary-article cover-image"
"small-article1 small-article2 small-article3";
gap: 20px;
}
.title {
grid-area: title;
text-align: center;
}
.feature-article {
grid-area: feature-article;
}
.cover-image {
grid-area: cover-image;
}
.secondary-article {
grid-area: secondary-article;
}
.small-article1 {
grid-area: small-article1;
}
.small-article2 {
grid-area: small-article2;
}
.small-article3 {
grid-area: small-article3;
}
.cover-image img {
max-width: 100%;
height: auto;
display: block;
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36
Challenge Information:
Design a Newspaper Layout - Design a Newspaper Layout