skip to Main Content

remove the the highlighted part
so i was making a basic profile webpage with and css, but now i am facing a problem.
there is a large space b/w the div of class=".item", even though i have not given any. can anyone pls tell my why this is happening.
attaching a link to the webpage hosted on github:- https://saumya-aggarwal.github.io/Profile-page/ i have also attached the image, i have to remove the highlighted part.

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background-color: aliceblue;
  font-family: 'Lora', serif;
  font-size: 1rem;
}

.container {
  background-color: aliceblue;
  /* border: 2px solid rgb(149, 154, 158);  temporary border */
  width: 75%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr 2fr 2fr;
  grid-template-rows: 1fr 2fr 2fr 1fr auto;
  gap: 2rem;
  padding-top: 50px;
  padding-left: 30px;
  padding-right: 10px;
}

h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  margin: 0%;
  padding: 0%;
}

footer {
  background-color: #333;
  color: #fff;
  padding: 20px 0;
  text-align: center;
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
}

.profile {
  display: flex;
  flex-direction: column;
  grid-row: span 5;
  position: sticky;
  align-items: center;
  top: 10px;
  padding: 20px;
}

img {
  border-radius: 50%;
  -webkit-border-radius: 50%;
  -moz-border-radius: 50%;
  -ms-border-radius: 50%;
  -o-border-radius: 50%;
  width: 270px;
  aspect-ratio: 1;
  margin-bottom: 50px;
}

.link-container {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 20px;
}

.link-container a {
  color: #333;
  text-decoration: none;
  font-size: 1.5rem;
  font-weight: 600;
}

.name-info {
  grid-column: span 2;
  h1 {
    font-size: 2.5rem;
  }
  h3 {
    font-size: 1rem;
  }
}

.hobbies {
  grid-column: span 2;
}

.footer {
  grid-column: span 2;
}

.item {
  min-height: 200px;
  max-height: 300px;
  /* Adjust the minimum height as needed */
}

button {
  background-color: transparent;
  text-align: center;
  padding: 10px;
  border: none;
}

hr {
  width: 100%;
  border-bottom: 3px solid black;
  padding-bottom: 2px;
  margin-top: 5px;
}

.content {
  padding-top: 30px;
  li {
    list-style: none;
    padding-bottom: 20px;
  }
}
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Profile</title>
  <link rel="preconnect" href="https://fonts.googleapis.com">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
  <link href="https://fonts.googleapis.com/css2?family=Lora:wght@400;700&family=Playfair+Display:wght@400;700;900&display=swap" rel="stylesheet">
  <link rel="stylesheet" href="styles.css">
</head>

<body>
  <div class="container">
    <div class="profile item">
      <img src="profile.png" alt="Profile Picture">
      <div class="link-container">
        <h2>Socials</h2>
        <hr class="socials">
        <button><a href="#">Instagram</a></button>
        <button><a href="#">LinkedIn</a></button>
        <button><a href="#">GitHub</a></button>
        <button><a href="#">Email</a></button>
      </div>
    </div>
    <div class="name-info item">
      <h1>I am Saumya Aggarwal</h1>
      <h3>Innovative Web Developer | Tech Enthusiast | Hackathon Achiever</h3>
      <hr class="heading">
    </div>
    <div class="experience item">
      <h2>Experience</h2>
      <hr class="alternate-heading">
      <div class="content">
        <ul>
          <li><strong>Dynamic Web Projects</strong><br>Crafted multiple dynamic web projects using HTML, CSS, and JavaScript.</li>
          <li><strong>Python Automation</strong><br>Developed a Python project that stores records of employees in a company and performs certain tasks on it.</li>
          <li><strong>Team Collaboration</strong><br>Collaborated with cross-functional teams to deliver seamless and responsive web applications.</li>
        </ul>
      </div>
    </div>
    <div class="education item">
      <h2>Education</h2>
      <hr class="alternate-heading">
      <div class="content">
        <ul>
          <li><strong>B.Tech in Computer Science Engineering</strong><br>Maharaja Agrasen Institute of Technology<br>Expected Graduation: 2027</li>
          <li><strong>High School Diploma</strong><br>DAV Public School, Vasant Kunj</li>
        </ul>
      </div>
    </div>
    <div class="skills item">
      <h2>Skills</h2>
      <hr class="alternate-heading">
      <div class="content"></div>
    </div>
    <div class="achievement item">
      <h2>Achievement</h2>
      <hr class="alternate-heading">
      <div class="content">
        <ul>
          <li><strong>Hackathon Success</strong><br>Competed against hundreds of teams and secured a top 10 position in a hackathon, showcasing innovative problem-solving and teamwork.</li>
          <li><strong>Project Portfolio</strong><br>Created and deployed several small-scale projects, each highlighting different aspects of web development, from responsive design to interactive features.</li>
        </ul>
      </div>
    </div>
    <div class="hobbies item">
      <h2>Hobbies</h2>
      <hr class="alternate-heading">
      <div class="content">
        <ul>
          <li><strong>Web Development Enthusiast</strong><br>Constantly exploring new technologies and frameworks, building side projects to enhance skills and knowledge.</li>
          <li><strong>Music Lover</strong><br>Enjoys discovering new music and creating playlists.</li>
          <li><strong>Football Aficionado</strong><br>Regularly plays football, appreciating teamwork, strategy, and the physical challenge.</li>
          <li><strong>Video Editing</strong><br>Develops and edits video and image content.</li>
        </ul>
      </div>
    </div>
    <div class="footer item">
      <hr class="alternate-heading">
      <footer>
        <div class="footer-content">
          <p>&copy; 2024 Your Name</p>
        </div>
      </footer>
    </div>
  </div>
</body>

</html>

i read my code many times, used chrome developer tools to find why there is a extra space in b/w, asked chatgpt but couldn’t figure it out.

2

Answers


  1. Hello i’ve inspected your code you have added grid-template-rows to container div you can modify this line to grid-template-rows: 70px 1fr 1fr 1fr auto or make it as you see it good

    Login or Signup to reply.
  2. You need to slightly reorganize your HTML as below you first need 2 columns. Then the right side column needs to be split into 2 rows. the below rows the needs to be split into 3rows with 2 columns as follows. You need for that to add additional wrapping that you will style with and needed grid template column or rows ( note that the last row in the right is spanning 2 columns as you apparently wanted, and I removed the footer from the grid layout as well). Change the gap to also space it as you wish

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }
    
    body {
      background-color: aliceblue;
      font-family: 'Lora', serif;
      font-size: 1rem;
    }
    
    .container {
      background-color: aliceblue;
      /* border: 2px solid rgb(149, 154, 158);  temporary border */
      /* width: 75%; */
      margin: 0 auto;
      display: grid;
      grid-template-columns: 1fr 2fr;
      gap: 2rem;
      padding-top: 50px;
      padding-left: 30px;
      padding-right: 10px;
    }
    
    .wrapper_div{
      display: grid;
      grid-template-rows: auto 1fr;
      gap: 1rem;
    }
    
    .wrapper_div2{
      display: grid;
      grid-template-rows: auto 1fr;
    
      grid-template-columns: auto auto;
      gap: 1rem;
      /* grid-template-rows: 1fr 1fr; */
    }
    
    h2 {
      font-family: 'Playfair Display', serif;
      font-size: 2rem;
      margin: 0%;
      padding: 0%;
    }
    
    footer {
      width: 100%;
      height: 100%;
      bottom: 0;
      background-color: #333;
      color: #fff;
      padding: 20px 0;
      text-align: center;
    }
    
    .footer-content {
      max-width: 1200px;
      margin: 0 auto;
    }
    
    .profile {
      display: flex;
      flex-direction: column;
      grid-row: span 5;
      position: sticky;
      align-items: center;
      top: 10px;
      padding: 20px;
    }
    
    img {
      border-radius: 50%;
      -webkit-border-radius: 50%;
      -moz-border-radius: 50%;
      -ms-border-radius: 50%;
      -o-border-radius: 50%;
      width: 270px;
      aspect-ratio: 1;
      margin-bottom: 50px;
    }
    
    .link-container {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      gap: 20px;
    }
    
    .link-container a {
      color: #333;
      text-decoration: none;
      font-size: 1.5rem;
      font-weight: 600;
    }
    
    .name-info {
      grid-column: span 2;
      h1 {
        font-size: 2.5rem;
      }
      h3 {
        font-size: 1rem;
      }
    }
    
    .hobbies {
      grid-column: span 2;
    }
    
    /* .footer {
      grid-column: span 2;
    } */
    
    /* .item {
      min-height: 200px;
      max-height: 300px;
      Adjust the minimum height as needed 
    } */
    
    button {
      background-color: transparent;
      text-align: center;
      padding: 10px;
      border: none;
    }
    
    hr {
      width: 100%;
      border-bottom: 3px solid black;
      padding-bottom: 2px;
      margin-top: 5px;
    }
    
    .content {
      padding-top: 30px;
      li {
        list-style: none;
        padding-bottom: 20px;
      }
    }
    <div class="container">
        <div class="profile item">
          <img src="https://fastly.picsum.photos/id/3/5000/3333.jpg?hmac=GDjZ2uNWE3V59PkdDaOzTOuV3tPWWxJSf4fNcxu4S2g" alt="Profile Picture">
          <div class="link-container">
            <h2>Socials</h2>
            <hr class="socials">
            <button><a href="#">Instagram</a></button>
            <button><a href="#">LinkedIn</a></button>
            <button><a href="#">GitHub</a></button>
            <button><a href="#">Email</a></button>
          </div>
        </div>
        <div class="wrapper_div">
            <div class="name-info item">
              <h1>I am Saumya Aggarwal</h1>
              <h3>Innovative Web Developer | Tech Enthusiast | Hackathon Achiever</h3>
              <hr class="heading">
            </div>
            <div class="wrapper_div2">
            <div class="experience item">
              <h2>Experience</h2>
              <hr class="alternate-heading">
              <div class="content">
                <ul>
                  <li><strong>Dynamic Web Projects</strong><br>Crafted multiple dynamic web projects using HTML, CSS, and JavaScript.</li>
                  <li><strong>Python Automation</strong><br>Developed a Python project that stores records of employees in a company and performs certain tasks on it.</li>
                  <li><strong>Team Collaboration</strong><br>Collaborated with cross-functional teams to deliver seamless and responsive web applications.</li>
                </ul>
              </div>
            </div>
            <div class="education item">
              <h2>Education</h2>
              <hr class="alternate-heading">
              <div class="content">
                <ul>
                  <li><strong>B.Tech in Computer Science Engineering</strong><br>Maharaja Agrasen Institute of Technology<br>Expected Graduation: 2027</li>
                  <li><strong>High School Diploma</strong><br>DAV Public School, Vasant Kunj</li>
                </ul>
              </div>
            </div>
            <div class="skills item">
              <h2>Skills</h2>
              <hr class="alternate-heading">
              <div class="content"></div>
            </div>
            <div class="achievement item">
              <h2>Achievement</h2>
              <hr class="alternate-heading">
              <div class="content">
                <ul>
                  <li><strong>Hackathon Success</strong><br>Competed against hundreds of teams and secured a top 10 position in a hackathon, showcasing innovative problem-solving and teamwork.</li>
                  <li><strong>Project Portfolio</strong><br>Created and deployed several small-scale projects, each highlighting different aspects of web development, from responsive design to interactive features.</li>
                </ul>
              </div>
            </div>
            <div class="hobbies item">
              <h2>Hobbies</h2>
              <hr class="alternate-heading">
              <div class="content">
                <ul>
                  <li><strong>Web Development Enthusiast</strong><br>Constantly exploring new technologies and frameworks, building side projects to enhance skills and knowledge.</li>
                  <li><strong>Music Lover</strong><br>Enjoys discovering new music and creating playlists.</li>
                  <li><strong>Football Aficionado</strong><br>Regularly plays football, appreciating teamwork, strategy, and the physical challenge.</li>
                  <li><strong>Video Editing</strong><br>Develops and edits video and image content.</li>
                </ul>
              </div>
            </div>
        </div>
      </div>
    </div>
            
        <div class="footer item">
          <hr class="alternate-heading">
          <footer>
            <div class="footer-content">
              <p>&copy; 2024 Your Name</p>
            </div>
          </footer>
        </div>

    .

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search