Design a Blog Post Card - Design a Blog Post Card

Hi everyone i spent a lot of times building this, i just thought that would be nice to share with you the exercice finally solved.

Index.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link href="styles.css" rel="stylesheet"/>
    <title>Blog Post Card</title>
</head>
<body>
    <div class="container">
    <div class="blog-post-card">
    <img class="post-img" src="https://cdn.freecodecamp.org/curriculum/labs/cover-photo.jpg" alt="image d'un écran d'ordinateur">
    <div class="post-content">
    <h2 class="post-title">Learn Web Development in 2024</h2>
    <p class="post-excerpt">Stay ahead of the curve with the latest trends in web development. Discover what's new and exciting in 2024</p>
    <a class="read-more">Read More</a>
</div>
</body>
</html>

Careful all "class"are linked so don’t close the “div”.

Those are my own settings that i found myself it took a long time to find what could fit almost perfectly, try to find by yourself before to reveal the spoiler.

Good luck Friends !

Styles.css_Solution
body{
  background-color: rgb(206, 206, 189);
  font-family: Arial, sans-serif;
}
.blog-post-card{
  background-color: white;
  border-radius: 10px; 
  width: 350px;
  margin: 125px auto;
  text-align: center;
}
.post-img{
  border-radius: 5px;
  border-bottom: 4px solid rgba(0, 0, 0, 0.587);
  width: 100%;
}
.post-content{
  padding: 5px;
  width: 80%;
  text-align: center;
  margin-left: auto;
  margin-right: auto;
}
.read-more{
  color: white;
  background-color: rgba(37, 35, 35, 0.868);
  margin-top: 3px;
  margin-left: 10px;
  margin-right: 10px;
  margin-bottom: 30px;
  display: inline-block;
  border-radius: 4px;
  padding: 10px;
  text-align: center;
}
.read-more:hover{
  background-color: orange;
}
.post-title{
  margin: 4px;
  color: rgba(0, 0, 0, 0.861);
}
.post-excerpt{
  margin-bottom: 20px;
  margin-top: 10px;
  color: rgba(0, 0, 0, 0.799);
{

Why would you not close your div elements? Closing an element has nothing to do with styling.

Cause when i closed it it wouldn’t work with the checkpoint i so i just close the div at the end of the code not everytime, i mean i didn’t use /div un til the end of the code

There is a small error in your stylesheet. The closing curly brace for your .post-excerpt selector is flipped.

1 Like

Thanks you i haven’t noticed it !