What could be the reason behind the significant void in the grid I designed?

I'm currently learning how to utilize the grid container and have successfully created a grid with 2 images on top, 2 on the bottom, and one that stretches vertically on the left side. While I have arranged the grid as desired, I am facing an issue with a large gap between each image. Despite adjusting the grid gap and even removing it altogether, the gap remains unchanged. How can I resolve this problem?

Thank you.

.PopDestination-Header{
    text-align: center;
    margin: 100px;
}
.grid-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(4, 1fr);

  }
  .grid-item-1 {
    grid-column: 1/2;
    grid-row: 1/3;
  }
  .grid-item-2 {
    grid-column: 2/3;
    grid-row: 1/2;
  }
  .grid-item-3 {
    grid-column: 3/4;
    grid-row: 1/2;
  }
  .grid-item-4 {
    grid-column: 2/3;
    grid-row: 3/4;
  }
  .grid-item-5 {
    grid-column: 3/4;
    grid-row: 3/4;
  }
<section class="PopularDestination">
        <div class="PopDestination-Header">
            <h1>Popular Destination</h1>
        </div>
        <div class="grid-container">
           <div class="grid-item-1"><img src ="Images/meric-dagli-CK_MX9mBGRo-unsplash.jpg" height="700" width="350"></div>
           <div class="grid-item-2"><img src ="Images/doug-watanabe-9uiUGnGeeUo-unsplash.jpg" height="350" width="500"></div>
           <div class="grid-item-3"><img src ="Images/ryan-stone-VnZMKbXrA0I-unsplash.jpg" height="350" width="500"></div>
           <div class="grid-item-4"><img src ="Images/clay-elliot-3xJAVC07AYk-unsplash.jpg" height="350" width="500"></div>
           <div class="grid-item-5"><img src ="Images/mike-dierken-KmA5OdUkAj8-unsplash.jpg" height="350" width="500"></div>
        </div>
    </section>

https://i.sstatic.net/rjWDP.jpg

Answer №1

After making some adjustments to your code, here is the updated version. I hope it functions correctly for you. To get the best view, please run the code snippet in full-screen mode.

.PopDestination-Header{
  text-align: center;
  margin: 100px;
}
.grid-container {
  display: grid;
  grid-template-columns: auto auto auto;
  grid-template-rows: auto;
  grid-column-gap: 30px;
  grid-row-gap: 30px;
  justify-content: center;
}

.grid-item-1 {
  grid-column: 1/2;
  grid-row: 1/4;
}
.grid-item-2 {
  grid-column: 2/3;
  grid-row: 1/2;
}
.grid-item-3 {
  grid-column: 3/3;
  grid-row: 1/2;
}
.grid-item-4 {
  grid-column: 2/3;
  grid-row: 2/2;
}
.grid-item-5 {
  grid-column: 3/3;
  grid-row: 2/2;
}
<section class="PopularDestination">
    <div class="PopDestination-Header">
        <h1>Popular Destination</h1>
    </div>
    <div class="grid-container">
       <div class="grid-item-1"><img src ="https://picsum.photos/211" height="700" width="350"></div>
       <div class="grid-item-2"><img src ="https://picsum.photos/222" height="350" width="500"></div>
       <div class="grid-item-3"><img src ="https://picsum.photos/256" height="350" width="500"></div>
       <div class="grid-item-4"><img src ="https://picsum.photos/247" height="350" width="500"></div>
       <div class="grid-item-5"><img src ="https://picsum.photos/265" height="350" width="500"></div>
    </div>
</section>

The gaps between columns and rows are displayed like this in the Chrome browser:

https://i.sstatic.net/Gz5Ul.jpg

Answer №2

.grid-item-4 {
  grid-column: 1/2;
  /* grid-row: 2/3; */
  grid-row: 1/2;
}

.grid-item-5 {
  grid-column: 2/3;
  /* grid-row: 2/3; */
  grid-row: 1/2;
}

Answer №3

Give this a shot

.container {
  max-width: min-content;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Difficulty with navigation buttons on multiple Bootstrap carousels implemented using ngFor in a single page

Currently, I'm engaged in developing a practice eCommerce platform where multiple product cards are showcased using data from a sample JSON file. Additionally, several Bootstrap carousels are integrated into the website to display images of each item. ...

The unique GopikaTwo Gujarati font is unfortunately not compatible with Android mobile browsers and hybrid applications

I am currently trying to incorporate the custom font GopikaTwo into my hybrid application. Below is the code snippet I have added to my CSS file: @font-face { font-family: 'GopikaTwo' !important; src: url('GopikaTwo.eot') !impo ...

Using HTML to load an image is not possible, as it can only be done using CSS

I am currently dealing with a CSS issue in my project. Here is the code snippet from my stylesheet: .Img{ background: url('../assets/Trump.png'); } Now, let's take a look at the corresponding HTML code: <div class="Img"> However, ...

Nested Divs in CSS

I'm really struggling to get a div to display under another div in the way they usually do. Currently, I am using MaterializeCSS for my layout setup: <div class="container valign-wrapper"> <div class="customClass"></div> &l ...

Center column with header and footer flanking each side

Trying to replicate the layout of the Facebook Android app on my page. The app features a 3 column design, with the central column exclusively displaying the header (no footer included, although I require one for my version). This visual representation is ...

Utilize Javascript to conceal images

On a regular basis, I utilize these flashcards. Recently, I have started using images as answers. However, I am facing an issue - I am unable to conceal the pictures. My preference is for the images to be hidden when the webpage loads. function myShowTe ...

What are the steps for showcasing a personalized HTML tag on a web page

I need to capture user input text and display it correctly. This is what I have attempted: <div> <input type="text" ng-model="post.content" /> </div> <div> <div ng-bind-html="post.content| htmlize"></div> < ...

What could be the reason my website is not saving the user input information to the database?

Hello! I am a novice programmer attempting to create a basic registration function on my website. I have set up a simple form for users to input their information, but I am facing an issue where the user data is not being stored in my database. ...

Delete the initial double line break and then switch the remaining double line breaks to single line breaks

I am facing an issue with some HTML content fetched from an external source. My aim is to specifically target instances of double br tags using jQuery. I want to delete the first occurrence of double br and convert all subsequent occurrences into single br ...

The Bootstrap modal backdrop is now displaying prominently in front of the modal following the latest Chrome update

Chrome version: Version 111.0.5563.64 (Official Build) (x86_64) Bootstrap: 4.3.1 Recently, there has been an issue with the modal backdrop appearing in front of the modal itself after a Chrome update. The problem does not seem to be related to z-index, an ...

Embarking on the journey of nesting components within styled-components

Check out these custom components I created: <UserImg imgUrl={userPhoto}> <DropDown> <div onClick={handleAuth}>Sign Out</div> </DropDown> </UserImg> const DropDown = styled.div` letter-spacing: 0.2em; positi ...

Can a horizontal navigation bar be designed to span the full width of the page without relying on a table?

I'm trying to create a horizontal navigation menu with variable width buttons that spans the full width of the containing div. I was successful in achieving this by using a table, as demonstrated in this example. The table cells adjust their size base ...

extracting the identifiers and class names from an HTML document

I have successfully extracted tags from an HTML file using getElementByTagName. However, I am also interested in parsing the IDs and class names within the same HTML file. This is my current approach: $html = new DOMDocument(); $html->loadHTML ...

html form-- assistance required in making new input area appear upon clicking radio button

Currently, I am in the process of creating a basic customer database using mysql and php. My goal is to have extra input fields appear for mailing address when users click on the radio button labeled "different mailing address". However, I'm unsure ab ...

creating a mixin for a box-shadow value of none in LESS CSS

I'm encountering a challenge with implementing the box-shadow mixin in LESS css. Here's the mixin for box-shadow: .boxShadow (@x, @y, @blur, @spread: 0, @alpha) { -webkit-box-shadow: @x @y @blur @spread rgba(0, 0, 0, @alpha); -moz-box-s ...

Tips for incorporating animated features into a bar graph using jQuery

How can I create a dynamic animated bar graph using jQuery? I am looking to make the bar slide up from the bottom, incorporating images for both the bar and background. I have already set the positioning in CSS and now need to add animation to make the bar ...

Adding a code for divs into CSS caused the navigation bar to be completely obliterated

Initially, my menu was perfectly styled with the following CSS code in my css file: ul.Menu { list-style-type: none; margin: 10px; overflow: hidden; background-color: #ffffff; border-style: solid; border-color: #e9055c; border-width: 2px; font-weight: bol ...

What is the reason for the Pointer Lock API entry displaying a significant number when the window is compressed?

Take a look at these two screenshots that illustrate the issue: The first screenshot demonstrates the correct behavior - the fullscreen mode works perfectly. However, in the second screenshot, a problem arises. Depending on the size of the browser window, ...

I am experiencing a problem with my Dynamic Table where it duplicates the titles every time a new entry

Attempting to generate dynamic tables using the Repeat Region feature in Dreamweaver CS5 is causing an issue where each new record entry also repeats the table titles when viewed in a browser. COMPANY REF DATE highbury 223333 2014- ...

Implementing a redirection of Dojo Data grid cell values to a different destination

I am working with a Dojo data grid that contains 10 rows (cells) of values. When the first row is clicked, I need it to redirect to another HTML page and carry along the values from the first row. Can you assist me in achieving this functionality? ...