What could be causing my CSS grid items to overlap each other in a specific arrangement?

I am new to CSS grid layout and currently experimenting with grid-template-areas to create a grid layout.

However, I am facing issues with items overlapping because I have set the height of the map item explicitly. When changed to auto, the map disappears.

Adding to the complexity, I am using nested grids, but it seems like the map content is causing the problem. I also tried arranging my grid in a 3x1 layout for mobile display, but the map keeps going beyond its boundaries. Even after using grid-template-rows to fix this, the final results are not satisfactory.

I could really use some guidance on how to solve these problems. Any help would be greatly appreciated.

     #maincontent {
              background-color: #f3f3f3;
              min-height: 100%;
              height: auto;
              width: 100%;
              max-width: 100%;
              overflow-x: hidden;
              overflow-y: hidden;
              position: relative;
            }

            #footer {
              background-color: #444;
              color: #aaa;
              font-size: 8pt;
              letter-spacing: 1px;
              padding: 25px;
              text-align: center;
              text-transform: uppercase;
              width: auto;
              /*width: calc(50% - 80px);*/
            }



            /* ====================== Map ====================== */

            #map {
              height: 300px;
              width: 100%;
              background-color: #ccc;
            }

            #map-container {
              grid-area: content;
            }


            /* ====================== Restaurant Filtering ====================== */

            .filter-options {
              display: grid;
              width: 100%;
              height: 50px;
              background-color: #3397DB;
              align-items: center;
              grid-template-areas: "select1 select2";
            }

            .filter-options h2 {
              color: white;
              font-size: 1rem;
              font-weight: normal;
              line-height: 1;
              margin: 0 20px;
            }

            .filter-options select {
              background-color: white;
              border: 1px solid #fff;
              font-family: Arial, sans-serif;
              font-size: 11pt;
              height: 35px;
              letter-spacing: 0;
              margin: 10px;
              padding: 0 10px;
              width: 200px;
            }


            /* ====================== Restaurant Listing ====================== */

            #restaurants-list {
              display: grid;
              grid-template-columns: repeat(4, 1fr);
              grid-gap: 10px;
              grid-auto-flow: row;
              grid-area: auto;
              background-color: #f3f3f3;
              list-style: outside none none;
              margin: 0;
              padding: 30px 15px 60px;
              text-align: center;
            }

            #restaurants-list li {
              background-color: #fff;
              border: 2px solid #ccc;
              font-family: Arial, sans-serif;
              margin: 15px;
              min-height: 380px;
              padding: 0 30px 25px;
              text-align: left;
              width: 270px;
            }

            #restaurants-list .restaurant-img {
              background-color: #ccc;
              display: block;
              margin: 0;
              max-width: 100%;
              min-height: 248px;
              min-width: 100%;
            }

            #restaurants-list li h1 {
              color: #f18200;
              font-family: Arial, sans-serif;
              font-size: 14pt;
...
</stylesheet>

            <body class="inside">
  <div class="wrapper">
  <header id="header" class="restaurant-header">
    <nav>
      <h1><a href="/">Restaurant Reviews</a></h1>
    </nav>
    <ul id="breadcrumb">
      <li><a href="/">Home</a></li>
    </ul>
  </header>
  
        <div id="maincontent" class="restaurantMainContent">

          <section id="map-container" class="map-container-class">
            <div id="map"></div>
          </section>


          <div id="restaurant-container">
            <div id="restaurant-name-div"> <p><h1 id="restaurant-name"></h1></div>
            <div id="restaurant-img-div"><img id="restaurant-img" alt="Image of the restaurant selected"></di...
            <div id="restaurant-cuisine"></div>
            <div id="restaurant-address"></div>
            <div id="restaurant-hours-div">
              <table id="restaurant-hours"></table>
            </div>
          </div>

        
      
        <div id="reviews-container-div">
          <section id="reviews-container">
            <ul id="reviews-list"></ul>
          </section>
        </div>
       
    </div>



      <footer id="footer" class="restaurant-footer">
        Copyright (c) 2017 <a href="/"><strong>Restaurant Reviews</strong></a> All Rights Reserved.
      </footer>
    

Answer №1

After some exploration, I discovered the answer! By including grid-auto-rows: minmax(300px, auto) in the grid where my map, restaurant, and reviews containers are located, everything fell into place perfectly!

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

A duo of adjacent buttons styled with HTML, CSS, and Bootstrap

I'm encountering an issue with the layout of my design. On my product page, I have two buttons placed on top of each other because one is within a form (refer to the image). https://i.sstatic.net/cS9TI.jpg I would like to position the two buttons s ...

Adaptable arrow-shaped progress bar featuring sleek transparent borders

I am currently working on creating a progress bar similar to those commonly found in checkout processes. One issue I have encountered is that the borders between the arrows appear transparent, and the entire design needs to be responsive. So far, I have m ...

Ensure that the entire webpage is optimized to display within the viewport

My goal is to make the entire website fit perfectly into the viewport without requiring any scrolling. The main pages I am focusing on are index, music, and contact, as the other two pages lead to external sources (you can find the link at the bottom of th ...

Manipulating classes within ng-class in AngularChanging classes in ng-class dynamically

Featuring multiple elements with an ng-class that behaves similarly to a ternary operator: ng-class="$ctrl.something ? 'fa-minus' : 'fa-plus'" To access these elements, we can compile all the ones with fa-minus and store them in a lis ...

What causes a slow disappearance of both the form element and its child elements when the visibility attribute is set to hidden on the

Have you ever noticed that the child elements of an element form hide slowly when using visibility:hidden, but hide quickly when using display:none? This slow hiding can negatively impact user experience. I tried to find information on this issue, but eve ...

The Div ID is built utilizing attributes inherited from the preceding element

I'm encountering an issue where I've defined rollover buttons and div ids to manipulate my image positions. However, when I create a new div called Text and add content to it, the rollover buttons also seem to activate? It's as if the code f ...

Linked CSS Bullet Points

Typically, I focus on the backend of websites, but I am now attempting to add a new feature to my resume site. I want to connect bullet points with a vertical line that breaks at each point and does not overlap with the bullets themselves. I have created ...

What is the specific process of rendering a <button> element in a web browser?

What is the reason behind the <button> always having its text vertically aligned, while an anchor tag with the same styles does not? By "same styles" we mean that both elements have the same display, padding, line height, text-align, and vertical-al ...

Tips for displaying two HTML input elements side by side in a single row

This block of code HTML <input type="text" name="category" id="category" value="">&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" name="category_1" id="category_1" value="" tabindex="1"></div> Despite multiple attempts such ...

Is there a way to automatically extend my content to fill the space on the page below the Material UI AppBar?

I am currently using React and Material UI React to develop my application. My goal is to implement the AppBar component with content underneath, without causing the entire page to scroll. I want the content to occupy the maximum remaining height and the f ...

Determine whether an element has the capability to hold text content

Is there a surefire and reliable method to determine if an HTML element is capable of holding text, using only pure JavaScript or jQuery? For example, <br>, <hr>, or <tr> cannot contain text nodes, whereas <div>, <td>, or < ...

Executing transitionend Using Jest for Unit Testing

I am currently utilizing angular 8 along with Jest for unit testing. My challenge lies in adding a listener for the 'transitionend' event on an element, and I'm struggling to find a way to simulate/mock this event using Jest. this.animatedEl ...

What is the best way to extract the body content from a Markdown file that includes Frontmatter

How can I retrieve the content of the body from my markdown file using front matter? Currently, it is displaying as undefined. What steps should I take to fix this issue? {latest.map(({ url, frontmatter }) => ( <PostCard url={url} content={frontmat ...

Ways to automatically fill HTML code with a value from a input on the previous page stored in the URL parameters

Seeking assistance with incorporating a custom query string value from the URL into the default value of my HTML code. I need guidance on how to substitute the placeholder text "URL VALUE" with the actual value retrieved from the URL. https://i.sstatic.ne ...

Disable onclick action for programmatically created buttons

I'm facing an issue with the code I'm using to delete messages on my website. The problem is that while newly added messages are being dynamically loaded, the delete button (which links to a message deletion function) does not seem to be working. ...

Using jQuery to modify the CSS of a div located outside of an iframe

Currently, I am developing a straightforward script. Firstly, here is all of the code that I have: <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script type="text/javascript"> function SuperWebF1() { $("#outerd ...

Issues with CSS arising from conflicts in MUI alert component styling

My experience with Material UI 5.10.11 has been mostly positive, but I have encountered some issues with the MuiAlert component. When setting severity to 'error', it should look like this https://i.sstatic.net/A1KIE.png However, on certain pages ...

What is the best place in Rails to add @media CSS tags?

Currently, my layout.html.erb contains some CSS rules with @media queries. <style> @media (max-width: 900px) { .green-button{ display: none!important; } .chat_button{ margin-top: 20px!important; } #myCarousel{ ...

Trouble with JavaScript loading in HTML webpage

<!DOCTYPE html> <html> <head> <title>Breakout Game</title> <link rel="stylesheet" href="css/style.css"> </head> <body> <canvas width="900" height="450" class="canvas"></canvas> ...

Could someone please assist me in figuring out the issue with my current three.js code that is preventing it from

Recently, I decided to delve into learning three.js and followed the getting started code on the official documentation. However, I encountered a frustrating issue where the scene refused to render, leaving me completely perplexed. Here is my index.html: ...