Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to fix the padding inside the grid?

I have created two grids and set their background image. The h3 heading inside the grid is not properly placed. There is a minor gap between the heading "Biryani" and the bottom of the grid. I have tried to remove all padding but the heading doesn’t properly sit to the bottom of the grid. See the picture here and find the code below.
enter image description here

.all-recipes-grid {
  display: grid;
  grid-template-columns: 50vw 50vw;
  padding-top: 10px;
  padding-left: 20px;
  column-gap: 40px;
}

.recipe {
  padding: 20px 0px 0px 0px;
  font-size: 5px;
  border: 1px solid black;
  height: 400px;
  width: 600px;
  display: flex;
  align-items: flex-end;
  text-align: left;
}

.recipe h3 {
  background-color: rgb(230, 230, 230);
  width: 50vw;
  padding-left: 20px;
  height: 100px;
}

.biryani {
  background-image: url('https://images.unsplash.com/photo-1589302168068-964664d93dc0?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8YmlyeWFuaXxlbnwwfHwwfHw%3D&auto=format&fit=crop&w=500&q=60');
  background-size: cover;
  background-position: center;
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link rel="stylesheet" href="index.css">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
  <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>

  <title>Recipes Website</title>
</head>

<body>
  <div id="nav-bar">
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
      <div class="container-fluid">
        <a class="navbar-brand" href="#">Mustaf Recipe</a>
        <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
              </button>
        <div class="collapse navbar-collapse" id="navbarSupportedContent">
          <ul class="navbar-nav me-auto mb-2 mb-lg-0">
            <li class="nav-item">
              <a class="nav-link active" aria-current="page" href="/odin-recipes/index.html">Home</a>
            </li>
            <li class="nav-item">
              <a class="nav-link" href="#">Recipes</a>
            </li>
            <li class="nav-item dropdown">
              <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
                      Trending
                    </a>
              <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
                <li><a class="dropdown-item" href="/odin-recipes/recipes/beef-karahi.html">Beef Karahi</a></li>
                <li><a class="dropdown-item" href="/odin-recipes/recipes/mutton-karahi.html">Mutton Karahi</a></li>
                <li><a class="dropdown-item" href="/odin-recipes/recipes/nihari.html">Nihari</a></li>
                <li><a class="dropdown-item" href="/odin-recipes/recipes/pulao.html">Pulao</a></li>
                <li><a class="dropdown-item" href="/odin-recipes/recipes/biryani.html">Biryani</a></li>
              </ul>
            </li>
          </ul>
          <form class="d-flex">
            <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
            <button class="btn btn-outline-success" type="submit">Search</button>
          </form>
        </div>
      </div>
    </nav>
  </div>
  <div class="all-recipes-grid">
    <div class="biryani recipe">
      <h3>Biryani</h3>
    </div>
    <div class="beef-karahi recipe">
      <h3>Beef Karahi</h3>
    </div>
  </div>
</body>

</html>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

By default heading elements have margin on the bottom. You need to remove that margin for h3.

Try this:

.recipe h3 {
   margin-bottom:0;
}

enter image description here

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading