Ways to eliminate the final empty space in a grid

Looking to create a layout with 5 boxes? Currently, I have managed to set up the grid structure, but the issue is that there is still some space below the last item in the grid. Below is the styled component for Container:

const Container = styled('div')`
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: 2fr 3fr 1fr;
  grid-template-rows: 5fr 0.75fr 1fr;
  gap: 10px;
  & > div {
    min-height: 20px;
  }
  & > .container-live-call {
    grid-column: 1 / span 3;
    background-color: ${({ theme }) => theme.color.secondary.$100};
  }
  // More styling code here
`;
<Container>
 <div className="container-live-call"></div>
 <div className="container-live-call-map"></div>
 <div className="container-live-call-info"></div>
 <div className="container-live-call-volume"></div>
 <div className="container-live-call-voice">
   <button onClick={() => setOpen(false)}>Click me to close</button>
 </div>
</Container>

Answer №1

Changing the .container-live-call-map and .container-live-call-info rules to start at row 2 and span 3 rows instead of adding an additional row, will align the total rows with what is defined in grid-template-rows.

.container  > .container-live-call-map {
    grid-row: 2 / span 2;
}
.container  > .container-live-call-info {
    grid-row: 2 / span 2;
}

This adjustment should eliminate any extra row or gap below the last item of the grid.

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

Maintaining a sticky footer that remains visible throughout the content as the screen is resized

For more information, please visit my website at I attempted to implement a "sticky footer" technique following the steps outlined in this tutorial (http://ryanfait.com/sticky-footer/) Unfortunately, the sticky footer does not function properly when resi ...

Programmatically control the opening and closing of a React Material UI Snackbar component

Currently, I am facing some challenges while working on programming a Single Page Application (SPA) using React and Material-UI. In my project, I have created a modal login box that gets triggered by a button on the navigation bar. Upon clicking submit, I ...

JS glitch leading to oversized window dimensions - Issue with dropdown menu

I recently integrated a dropdown into my website using Foundation CSS. To see the dropdown in action, you can login with the credentials provided (username: stackoverflow password: testtest) on . However, I noticed that when logged in, the page on the rig ...

Is it possible to represent a recursive variable using CSS?

When it comes to the html structure: <body> <div> <div> <div> ... </div> </div> </div> </body> Is there a method to create recursive variables that utilize their parent's value: body ...

Conceal the parent div from its sibling within the same parent container

My goal is to conceal a parent component from its child element. I attempted to achieve this by using the parent component as a background while adding additional backgrounds to the child elements for overriding purposes. However, this method did not work ...

Tips for modifying CSS when a user scrolls beyond a specific div

Currently, I am working on implementing a scroll function that dynamically moves elements based on the user's scrolling behavior. The code I have written works to some extent and successfully moves the elements. However, my goal is to create a list o ...

MaterialUI React components being stacked on top of each other

Currently working on a project with React and MaterialUI. Just about done with the setup, but I've run into an unexpected issue. The problem is that my simple navbar is overlapping the content beneath it. I set up a code sandbox to demonstrate the i ...

Tips on preventing the first letter from being capitalized in an input field

Currently, I am developing a React web application primarily used on mobile devices. We have an input field and our goal is to ensure that the first letter entered is not automatically capitalized. The input field can still contain capital letters, but ...

How to Preserve Scroll Position when Toggling a Div using jQuery

I've been struggling to find a solution for maintaining the scroll position of my page after a JQUERY toggle event. I've searched extensively but haven't found a fix yet. <script src="Scripts/_hideShowDiv/jquery-1.3.2.min.js" type="text/ ...

Is there a way to manually trigger a re-render of all React components on a page generated using array.map?

Within my parent component (Game), I am rendering child components (Card) from an array. Additionally, there is a Menu component that triggers a callback to Game in order to change its state. When switching levels (via a button click on the Menu), I want a ...

Updating state using the react `setState()` function will automatically trigger a re-render

I am currently working on a large form using React and material-ui. The form implements two-way binding to update the state when input changes occur. Interestingly, changing any input field triggers updates in all components (as observed through TraceRea ...

What is the best way to show hidden content within a masked div, similar to a tooltip?

In an icon-based menu, a grid consists of several <div> elements. Each element is empty with general CSS styling and inline CSS to set the mask effect. The purpose of using images as masks is to allow the icons to be colored in different ways by cha ...

Unlinked from the main content, the Angular2 Material2 sidenav stands on its

I am in the process of implementing the material2 sidenav component. My goal is to have a standalone, full-height sidebar that smoothly slides in and out without any interference with the rest of the app layout caused by the sidenav-layout. The desired ou ...

Preventing mouse clicks on checkboxes and triggering events using JavaScript - a complete guide

We have a Table grid with multiple columns, one of which is a Select Box (CheckBox). The expected behavior is that when a row is clicked, the respective CheckBox should get checked, and clicking on the CheckBox itself should update it. I tried implementin ...

Using Material UI styling alongside Next.js may cause unexpected issues

I've been facing issues while transitioning a project from plain React to Next.js. Even after trying to copy the files to another working Next.js project, the problem persists. It appears that the project breaks consistently in production but only sp ...

State change shows the previous and current values simultaneously

I've been working on updating the values of initUsers on the DOM. The initial state values work fine, but when I try to update initUsers, it displays different values than expected. Essentially, entriesNum receives a number as an event and changes th ...

Highlighting rows using jQuery upon selecting checkboxes

I attempted to emphasize a row in a table using jQuery when the checkbox is checked. This is the jQuery code I used for this purpose: $(":checkbox").change(function() { $(this).closest("tr").toggleClass("highlight", this.checked); }); However, it see ...

Manage the size of the menu element within Material-UI

I'm currently working on incorporating a menu item with a login form inside it. The functionality is there, but the width of the form is way too small. I've been searching through the documentation for a solution, but haven't come across any ...

The layout experiences sudden scrolling adjustments when inserting a new HTML element while using the MUI Menu component

I am facing an issue with my HTML layout where I have a Button connected to the Mui Menu and I want to insert a div above the Button. Here is a short example: <div id='initially-not-rendered-div' style={{ height: ...

Tips for updating the content of a div with fresh data using a slideshow effect in jQuery

Imagine you have a div called A and an array filled with text data. When t=0, div A will display $data[0]. Then, after every n seconds, I want the div to show the next piece of data in the array. I am interested in creating a transition effect similar to ...