A fresh line making room in the MUI Grid layout

Looking at the image below, it seems that the blue block is rendered below both the red and green blocks. I actually need the blue block to render directly underneath the red block.

Is there a way to achieve this layout adjustment using MUI grid?

import * as React from "react";
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";

export default function BasicList() {
  return (
    <Box>
      <Grid container>
        <Grid item alignContent="center" justifyContent="center" md={6}>
          <Box style={{backgroundColor:"red"}} height={200}>
            MD = 6 Height = 200
          </Box>
        </Grid>
        <Grid item md={6}>
          <Box style={{backgroundColor:"green"}} height={600}>
            MD = 6 Height = 600
          </Box>
        </Grid>
        <Grid item md={6}>
        <Box style={{backgroundColor:"blue"}} height={200}>
            MD = 6 Height = 200
          </Box>
        </Grid>
      </Grid>
    </Box>
  );
}

https://i.sstatic.net/tmozS.png

Answer №1

To resolve the issue, combine the Red and Blue boxes into a single grid structure. The following code snippet demonstrates how this can be achieved:

import * as React from "react";
import Box from "@mui/material/Box";
import Grid from "@mui/material/Grid";

export default function BasicList() {
  return (
    <Box>
      <Grid container>
        <Grid item alignContent="center" justifyContent="center" md={6}>
          <Box style={{backgroundColor:"red"}} height={200}>
            MD = 6 Height = 200
          </Box>
          <Box style={{backgroundColor:"blue"}} height={200}>
            MD = 6 Height = 200
          </Box>
        </Grid>
        <Grid item md={6}>
          <Box style={{backgroundColor:"green"}} height={600}>
            MD = 6 Height = 600
          </Box>
        </Grid>
      </Grid>
    </Box>
  );
}

Assign each grid to a specific column within your design for better organization.

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 layout featuring nested buttons and links within a card element, utilizing the power of Link in NextJs

After extensive searching on S.O., I have been unable to find a solution that works flawlessly. The issue at hand involves a card component in a NextJs application that is encompassed within a <Link> tag. Additionally, there is another <Link> t ...

Adjust the placement of the material autocomplete popup icon

I am currently seeking a solution for adding a unique button to the end of a material autocomplete feature. The issue I am facing is that the popup icon is styled to appear at the end of the autocomplete input which complicates adding a button in that posi ...

Tips for creating a horizontally scrolling div

Here is the CSS for the div that needs to be able to scroll horizontally: .form-holder{ padding-left: 20px; width: auto; background: ; overflow-x: auto; max-height: 300px; padding-bottom: 30px; } Every ...

JavaScript is utilized to update HTML content through an Ajax request, but unfortunately, the styling is

Apologies for the unconventional title, I am currently in the process of creating a website. When the page is initially loaded, I call upon two scripts within the 'head' tag to create an attractive dynamic button effect. <script src="https:// ...

Bootstrap's versatile footer positioning adaptation

I am working with a simple layout design: +----------+ | Header | +----------+ | | | Content | | | +----------+ | Footer | +----------+ My goal is to ensure that the footer is positioned: at the bottom of the viewport when there ...

Are there any plugins available that can create a Ken Burns effect using JQuery?

All I need is a straightforward plugin, not one for creating slideshows. In this case, I only have 1 div and 1 image. The goal is to have the image animate within the div, shifting left/right or up/down without any white space visible. The size of the ima ...

Zurb's Vertical Navigation Bar: A Stylish and Functional Design

I attempted to replicate the left navigation bar from this link: The responsive navigation bar and contents on the right caught my attention. Currently, I am working on a project that requires a similar navigation bar. While I am proficient in HTML and C ...

Tips for building a homepage button with an image and text using HTML and CSS

My ultimate goal is to create a button for the main page. I am looking to place an image and text side by side within this button, with a click on it directing me to the main page. Unfortunately, I have been facing challenges in resizing or stretching the ...

Struggling to implement a vertical scroll bar within a nested div element

Struggling to make a scroll bar appear in the box-content div, even after adding 'overflow-y:auto'. My specific requirements are: The entire layout should adjust according to the browser height. This is why I've set #wrap { ... height: 50 ...

Issue with Image Transition while Linking

I have been attempting to create transitions between images using links. I followed the steps in 'Demo 6' from this page (http://css3.bradshawenterprises.com/cfimg/), but unfortunately, it did not work as expected on my testing website (danitheme ...

Exploring the benefits of using jQuery validation plugin with the latest version of

My current setup involves utilizing the jQuery validation plugin for handling form validation in JavaScript, along with Bootstrap 4 for styling. I have observed that I needed to customize errorPlacement, highlight, and unhighlight to ensure that validation ...

Encountering the error message "BarChart in react.js is not iterable"

I encountered an issue with the BarChart component: An error message saying "undefined is not iterable!" appeared. The API response I received looks like this: { "saleCharts": [ { "priceSum": 0, "categoryName&q ...

Adding extra spacing to a bootstrap container the correct way

Scenario: Increasing padding in container view sketch Hello there! I am currently using bootstrap scss in typo3 and having ws_scss compile it for me. I feel like the content area needs more padding to make it slightly smaller. Here are some basic details ...

The carousel control in Bootstrap-material-design is working intermittently but encountering a zone-aware error

I manually downloaded Bootstrap v4.0.0-alpha6 and placed bootstrap.min.js into assets/js, along with tether.min.js and jquery.min.js. I also integrated Bootstrap-material-design. By the way, I am using @angular/cli 1.0.0-rc0. To implement a carousel in my ...

Enhance your user interface with Material-UI radio buttons featuring the sleek "outlined" variant

Struggling to find a way to showcase Radio Buttons with the "outlined" style from FormControl. Working on developing an annotation form using React and MaterialUI. For instance: In the image above, it is evident that the radio button field stands out amo ...

"Incorporate Bootstrap drop-down and button together for a stylish group feature

I am looking to format the code below to resemble the layout shown in the image using Bootstrap 3.3. When there isn't enough space to show all elements in a single line, I want them to stack vertically so that each element utilizes the entire width of ...

Enhance your viewing experience by magnifying a specific element, all while maintaining full control to navigate

Is it possible to create a zoom effect on a webpage that focuses on one specific element while still allowing for navigation and scrolling? I have searched online for plugins like Fancybox and Zoomooz, but none of them offer the functionality I need. I sp ...

Tips for adjusting mat button color with CSS when hovering over it

How can I use CSS to change the color of a Material button when hovering over it? mat-raised-button color="primary">button</button> ...

Images with full-width will scroll horizontally

Is there a way to fix the horizontal scroll issue? <!DOCTYPE html> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="https:// ...

Retrieve the value of a field from a Formik form integrated with Material UI

I've been working on a way to disable a checkbox group depending on the selected value of a radio group. I took inspiration from the technique outlined in the final section of the Formik tutorial. Using React context has definitely helped clean up the ...