Unable to create a responsive layout because of the use of inline CSS with "margin"

Currently, I am working on a design for a webpage that must be responsive to large, medium, and small screens. To achieve this responsiveness, I am using Material UI Grid container and placing Chips inside it with the style={{ marginLeft: 60 }} from the second chip onward. However, when the screen size changes, these chips overlap each other without any responsive behavior. Below is the snippet of my code:

 <Grid container item xs={12}>
            <Grid container item xs={11}>
                <Grid item xs={2}>
                    <Chip/>
                </Grid>

                <Grid item xs={2} style={{ marginLeft: 60 }}>
                  <Chip/>
                </Grid>

                <Grid item xs={2} style={{ marginLeft: 60 }}>
                   <Chip/>
                </Grid>

                <Grid item xs={2} style={{ marginLeft: 60 }}>
                     <Chip/>
                </Grid>

                <Grid item xs={2} style={{ marginLeft: 57 }}>
                     <Chip/>
                </Grid>

            </Grid>
</Grid>

I am seeking advice on how to correct this design issue. Any suggestions would be greatly appreciated. Thank you in advance.

Answer №1

If you're looking to make your margin sizes flexible and responsive to different screen sizes, consider using relative values instead of static pixels. You can achieve this by adjusting the styling to something like style={{ marginLeft: '5%' }}, or by applying a className and implementing media queries in your CSS file to define breakpoints for specific screen sizes.

Opting for the latter approach will give you more control over the responsiveness of your design, which is particularly useful if adaptability across various devices is important.

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

Conceal the MUI data table until the file has been uploaded

I need to ensure that the data table remains hidden until I upload my file. Currently, the table appears as blank but I want it to only be visible after the file is uploaded. var selectedList = {}; const columns = [ { name: "id", label: "Select", o ...

Insert the URL into either a div or an iframe

It seems like a common issue. I've come across multiple solutions for this problem. using jquery load using iframe I attempted both methods but encountered difficulties in loading content. Specifically, I tried to load google.com and it didn't ...

Placement: fresh column in absolute position

Could someone please help me understand this situation? I have posted my code on jsfiddle. I am using Bootstrap 4. In my design, I have text placed over an image with the parent div having position:relative. The left div has position:absolute and left:2%, ...

Can IE(7?) cause distortion of backgrounds from sprites?

This task is giving me a headache. We're almost finished with revamping our website. The last step involves consolidating all the glyphs and icons into a sprite. These images are transparent .png files, so we made sure the sprite maintains transparen ...

Replacing the left styling using CSS

Struggling to adjust the position of a side panel that pops up when hovering over an option. This is the code I found in Chrome Developer Tools: <nav id= "side_nav" class= "sidebar-bg-color header-side-nav-scroll-show"> <ul ...

What is the best way to keep the heights of two divs in sync?

Is there a way to make two divs have the same height, even though their content determines their individual heights? I am looking for a solution that doesn't involve using a table or a parent div. I'm new to JavaScript, so I'm hoping there i ...

Adjust my website to fit various screen sizes and mobile devices

I'm encountering an issue on my website regarding resizing elements and content on various resolutions, particularly on mobile devices. You can view the website here. I've been testing it on both an iPad and a 14" laptop. While everything appear ...

The NextUI Table example encounters an issue with a TypeError, specifically stating that it is unable to read properties of undefined, specifically referring to the

Seeking assistance with a React error as I am relatively new to the framework. While I have some basic knowledge of client and server side rendering, this particular issue has stumped me. Following this example: Use Case Example When creating a table, yo ...

Distinguishing the dissimilarity in functionalities between InputProps disabled and disabled in MUI Text

There are various ways to disable the MUI textfield: You can disable it by directly passing the disabled prop. You can also disable it by passing InputProps: {{ disabled: true }}. Or you can disable it by passing inputProps: {{ disabled: true }}. The thi ...

Change the background color of a Bootstrap dropdown when toggled

I recently created this code snippet: <div class="dropdown"> <button class="btn btn-secondary dropdown-toggle buttonForProfile" type="button" id="dropdownMenuButton" data-bs-toggle='dropdo ...

Add a unique shape to the CSS clip property

Recently, I've been delving into the clip property of CSS and its ability to apply a rectangle or square object. Despite my research efforts, I haven't come across a clear answer to my question. Can you actually use a customized shape with the c ...

What is the best way to retrieve all Objects by a specific property in React when working with an array of Objects?

I am looking to create a multiple checkbox filter where selecting the 'Accessories' option will display items with the 'Accessories' value under the 'type' property. However, before I proceed with that, I need to ensure that I ...

Arrange photos in a grid using React Dropzone uploaders

I'm having trouble figuring out how to create a custom preview similar to an image set in a grid using the react-dropzone-uploader component for uploading multiple files. Currently, when I upload images, they are displayed as shown in my normal uploa ...

Error: Unexpected token < occurs when using SVG require in Jest

I'm struggling to locate the source of this error. Currently, I am working with Typescript in React and using Jest and Enzyme for unit testing. Below is a snippet from my Package.json file: "scripts": { "start": "node server.js", "bundle": ...

Scaling boxes responsively according to screen size utilizing Bootstrap

Creating a portfolio website with a carousel section to display completed projects in a 2x2 grid layout, transitioning to a 1x4 on smaller screens is proving to be quite challenging. After trying various methods from Bootstrap documentation and YouTube tut ...

"Enhance Your Website Navigation with HTML5 and CSS - Creating a Wide

I've spent a full day trying to solve this issue, but unfortunately, I haven't been able to achieve any results. My goal is to create a menu with collapsible links that expand horizontally when hovering over the parent <li>. Essentially, it ...

Steps for incorporating a storyline into a CSS Chart

I'm attempting to introduce a horizontal line at a specific point using chartscss.org For instance, on the given chart utilizing Charts CSS below, I'm aiming to include a horizontal line at 15.5... Similar to the illustration shown. I've e ...

The custom styles I've implemented for the MaterialUI Button component are being replaced by the .css-zln006-MuiButtonBase-root-MuiButton-root styling

My custom styling for the MaterialUI Button component is being overridden by the .css-zln006-MuiButtonBase-root-MuiButton-root class. Here is the code for my Material UI Button component: import { Button } from "@mui/material"; import useStyles from "./He ...

Tool for React Development and Server Hosting

Looking for guidance on setting up the development environment and server for a new project I am undertaking to further my learning. My goal is to utilize ReactJS with Bootstrap. In my previous experience with ReactJS, the build and server were already con ...

Have I incorrectly implemented responsiveness on my website?

I created my HTML using Bootstrap 3.3.7: <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="copyright" content= ...