"Items within mui Grid do not properly align within the Grid container

I'm struggling to fit two large Grid items inside a Grid container.

  • The Grid container needs to be 100% of the screen's height (or parent container)
  • Grid items are large and need to fill the container while remaining scrollable

Image #1 shows the current situation, whereas image #2 depicts what I am aiming for. https://i.sstatic.net/scSQG.png

Here is the code snippet:

  "@mui/material": "^5.14.15"
  import { Grid } from '@mui/material';


  <Grid container direction='row' style={{height: '100%', overflow: 'hidden'}}>
    <Grid item xs={6}>
            .......left large content.......
    </Grid>
    <Grid item xs={6}>
            .......right large content......
    </Grid>
  </Grid>

Although setting overflow: 'hidden' makes it look better, the content of each Grid item remains unscrollable (even after setting overflow: 'scroll'). Any suggestions?

Answer №1

After trying various approaches and seeing no concrete solution, I managed to resolve the issue using flexBox: https://example.com/image.png

Answer №2

Try using alignItems="stretch" on the main container to potentially fix this issue.

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

Trouble accessing setState within an axios call in ReactJs

I've encountered an issue while attempting to set the state of the variable isCorrectAnswer within an axios call. The error message Cannot read properties of undefined (reading 'setState') is showing up in the console log. What mistake am I ...

HTML Buttons Remain Selected After Being Clicked

Currently working on a calculator app for a class project but I've hit a roadblock while setting up keyboard listeners. The keyboard functionality is fine, however, when it comes to clicking on buttons, specifically the non-keyboard functions, they re ...

NextJs experiencing hydration issue due to a basic array.map operation

Having an odd hydration issue while working with NextJS. I could use some assistance figuring out what's causing it. I have an object that is being processed synchronously. When I stringify this object and render it, everything works fine without any ...

Instructions on how to navigate to the login page after clicking the logout button on the navbar header in a React application

Recently, I delved into the world of React and configured my react router in App.js as shown below: <BrowserRouter> <div className="App"> <Header /> <Switch> <Route exact path="/" component={Home}> ...

Try out React Snap and Skip Third-Party Requests for a faster website

Even though I have set skipThirdPartyRequests to true, react-snap is blocking all requests. While I understand this is normal behavior, I am facing a challenge with my own API. I need to send API requests to the same host (localhost:45678) that react-snap ...

Tips for effectively incorporating Formik within your Input component

To prevent repetition of the bootstrap divs/classes, I have designed an input component in this way: import React from "react"; import "./Input.css"; const Input = ({ name, label, error, ...rest }) => { return ( <div className="form-group"> ...

An issue occurred while attempting to execute the npm start command

While attempting to create a React project, I used npx create-react-app hello-react --use-npm and then navigated to the hello-react directory using cd hello-react. However, when I tried to run npm start, I encountered the following error: npm ERR! code ENO ...

Implementing the style tag within a view

In my exploration of various Razor views, I've noticed a common practice where developers include a <style> tag directly in the CSHTML file. While this method may seem to work without issue, it actually places the <style> tag within the & ...

The react-router routes are failing to provide the expected results as they are not displaying any content on the webpage upon rendering

Having recently started learning React, I am currently working on implementing routes for basic navigation of components on my homepage. Although I have included the necessary code in my homepage component, I still encounter an issue where nothing appears ...

Issue with a responsive CSS circle element that holds an image

I'm struggling to figure out how to create 9 responsive CSS circles in a row, with each circle containing an img tag rather than a background image. The goal is to center the img and resize it based on the size of its parent circle div. These 9 circle ...

Tips for preventing NextJS from including a dynamically imported component in the main _app.js bundle while utilizing Module Aliases

Currently, I am in the process of transforming some shared-ui components into dynamically imported ones within NextJS 11. I have set up module aliases using @nx/next:library, for example @my-site/shared-ui, all exported from an index.ts file as shown belo ...

What is the process for importing an md file in a create-react-app project using JavaScript?

Attempting to execute the blog example provided on Material UI's getting started page. However, encountering an issue with the source code: Inside blog.js import post1 from './blog-post.1.md'; . . . return( <Main>{post1}<Main/> ...

hiding html elements by using the display property set to none instead of physically removing

I am currently utilizing an if-else statement to display different HTML structures. As a result, the entire HTML is being rendered twice. Is there a way we can utilize 'display: none' instead? I attempted to use it in th ...

In an array where the first 3 images have been filtered using an if statement, how can I show the image at the 3rd index (4th image) starting from the beginning?

In my personal web development project, I'm using AngularJS for the front-end and .NET Core for the back-end to create a website for a musical instrument retailer. The model I'm working with is called "Guitar" and all the guitar data is stored in ...

Creating a transparent background for a Canvas animation with three.js and dat.gui

I'm struggling to set up a background animation on this canvas using three.js. However, the background renders as black instead of transparent. I attempted to adjust it with CSS by adding background-color:transparent;, but to no avail. I've searc ...

Tips for adjusting an image to fit your carousel

I am dealing with a carousel that has fixed dimensions (e.g., width=800px, height=450px), but the images I want to display in it have varying aspect ratios (16 : 9, 16:10, 1:1, etc.) and are larger than the carousel itself. I am attempting to resize all th ...

There has been an internal server error: TypeError occurred due to the inability to convert undefined or

I'm working on implementing signIn functionality using nextauth.js. Below is the code snippet I am using: import { getProviders, signIn as SignIntoProvider } from 'next-auth/react' import Header from '../../Components/Header' ...

The Express API is failing to recognize the data keys that were sent from the React frontend, despite being clearly specified

I am facing an issue while trying to send data to a REST API using React hosted in a separate application. The API does not seem to receive the keys sent, even though I checked the results in Chrome and found this output:(2) ["imageSrc", File]0: "imageSrc" ...

Is specificity a characteristic of JavaScript?

After setting a div in my HTML file to have a height of 100px and a width of 100px, I attempted to retrieve the height using JavaScript. This is what I tried: console.log(document.GetElementById("box").style.height); // The div had an ID of "box" and w ...

How can I retrieve a password entered in a Material UI Textfield?

My code is functioning properly, but I would like to enhance it by adding an option for users to view the password they are typing. Is there a way to implement this feature? const [email, setEmail] = useState(''); const [password, setPassword] = ...