Arranging elements in a Material-UI card in a horizontal layout

I am currently working on designing a user profile display. I want to create a card layout that showcases the details listed below. My goal is to have these items displayed side by side instead of being divided as shown in the image.

Despite trying to give each item a Grid Item, they still appear listed one below the other. I aim to have 'skills' and 'home phone' aligned in the same row while 'can also work' and 'cell phone' are placed side by side on another row.

https://i.stack.imgur.com/5OTh2.png

                        <Grid container spacing={32} justify="center">
                            <Grid item>
                                <PersonImage
                                    personId={metadata.id}
                                    height={175}
                                    width={175}
                                />
                            </Grid>
                            <Grid item style={{ flexGrow: 1 }}>
                                <Grid
                                    container
                                    spacing={0}
                                    direction="column"
                                    justify="center"
                                    alignItems="stretch">
                                    <Grid item xs={6}>
                                        <Card>
                                            <InfoLabel
                                                label="Skills"
                                                text={profile.skills}
                                            />
                                            <InfoLabel
                                                label="Can Also Work"
                                                text={profile.work}
                                            />
                                            <Grid
                                                container
                                                spacing={16}
                                                justify="center">
                                                <Grid item>
                                                    <InfoLabel
                                                        label="Home Phone"
                                                        text={
                                                            contactInfo.homePhone
                                                        }
                                                    />
                                                    <InfoLabel
                                                        label="Cell Phone"
                                                        text={
                                                            contactInfo.mobilePhone
                                                        }
                                                    />

                                                    <InfoLabel
                                                        label="Email"
                                                        text={contactInfo.email}
                                                    />
                                                </Grid>
                                            </Grid>
                                        </Card>

Answer №1

To achieve this, utilizing the Grid is your best option.

Your grid layout seems to have some issues, particularly with excessive spacing. It's crucial to keep the spacing below 12 units, as too much spacing can cause content to overflow into subsequent rows - which appears to be occurring in this case.

I've put together a sandbox demonstration to illustrate how you can configure your grid setup. While most of the styling is not included, the structure aligns with your desired outcome.

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

Having trouble getting my local website to load the CSS stylesheet through Express and Node.js in my browser

https://i.stack.imgur.com/qpsQI.png https://i.stack.imgur.com/l3wAJ.png Here is the app.js screenshot: https://i.stack.imgur.com/l3wAJ.png I have experimented with different combinations of href and express.static(""); addresses. However, I am ...

In Firefox, the content within the div element does not respect the maximum width set

My lengthy code won't wrap properly inside the td and div elements. It works fine in Chrome, but Firefox isn't cooperating. Any tips on how to fix this issue? I'm also open to other suggestions for improving my code (e.g. "reduce your use of ...

Adding a <span> element within an <h1> tag in WordPress

I am attempting to create this layout in Wordpress using the code <h1>This is my <span>title</span></h1>, but I am unsure how to incorporate a <span> tag within the <?php the_title(); ?> function. After consulting the c ...

Using jQuery UI to create a bouncing effect on a CSS sprite image

Want to give your social icons a bounce effect using jQuery UI Bounce? I'm following a template and some jQuery documentation, but having trouble getting it right. It seems like the sprite image for the icons might be causing the issue. Can someone h ...

Setting the color for the :hover and :active states on a react JSX component: A step-by-step guide

<button onClick={fetchExchangeRates} style={{ backgroundColor: `${selectedColor}` }} className="hover text-white px-3 py-1 flex justify-center items-center gap-2 text- rounded-md" > Convert <FontAwesomeIcon className=&apo ...

Remove the background color from a semi-transparent circular CSS div when it is being dragged

My circular div is being dragged for a drag and drop operation, but there's always a translucent square around it. How can I remove this unwanted effect? body{ background : #BBD1DF; } .dragdemo { width: 170px; height: 170px; line-hei ...

Alert: The prop type validation has encountered an issue. The prop `options` is specified as mandatory in `ForwardRef(Autocomplete)`, however, it is currently set as `undefined

Alert: The prop options is required for ForwardRef(Autocomplete), but it is currently set to undefined. at Autocomplete (http://localhost:3000/static/js/bundle.js:93934:83) Please help me fix this warning. Thank you in advance for your assistance. ...

Adding padding with and without child elements

As I work on styling a basic menu, I'm struggling to find a solution for adding padding to list items so they all have a consistent look. The challenge arises from the fact that I have an unordered list where list items may or may not contain an anch ...

The latest grid system in Bootstrap 5 is designed to streamline

I'm attempting to use Bootstrap 5 to create a grid system similar to the image shown below View Image I've been struggling to replicate the grid section shown in the attached image using Bootstrap 5. <div class="container-fluid"> ...

Splitting hyphenations

Check out my Codepen project I'm attempting to prevent word-breaks inside my .threadTitle class by using display: inline-block. While this solution works, the addition of a hyphen between two letters still causes a break. https://i.sstatic.net/q6ZMk ...

Tips for stopping the background color from affecting the text color

I'm dealing with a situation where I have an h6 nested inside a div. <div class="cylinder" data-v-5147e140=""> <div data-v-5147e140=""> <h6 class="quantite" data-v-5147e140="&qu ...

Adding multiple styles using ngStyle is currently not possible

When using ngStyle to add height and width styles to an img element, I encountered a strange issue: <img class="image-full-view" [ngStyle]="{'height': selectedImage.heightSize, 'width': selectedImage.widthSize}" [src]="selectedImage ...

Mobile device causing HTML margins to shrink

I've attempted to utilize a few posts here that discuss resizing for mobile devices, but unfortunately, I'm having trouble getting it to work correctly. The margins are causing all the elements to be squished together when viewing the site on a m ...

Display a division in C# MVC 4 when a boolean value is true by using @Html.DropDownList

I have multiple divs stacked on top of each other, and I want another div to appear when a certain value is selected. I'm familiar with using JavaScript for this task, but how can I achieve it using Razor? Below is a snippet of my code: <div id=" ...

Issue with horizontal scrolling functionality in DataTables

I have a table with over 10 columns, and I am using datatables to display the data. I have enabled horizontal scrolling due to the large number of columns, but the scroll is not appearing. Can someone please assist me with this issue? Here is a screenshot ...

`How can I apply classes to all Material UI Dialogs across the board?`

I have numerous Material UI dialogs that need the rg-dialog class applied to all of them. What is the best way to achieve this? <Dialog classes={{ root: 'rg-dialog' }} open={workflowHistoryDialogVisible} > <DialogTitle>Hi ...

Spacing between table cells is only applied to the first row and footer

In an attempt to add spacing between the first row, second row, and footer of a table, I have experimented with cell spacing combined with border-collapse. However, the spacing is being applied all over the table instead of in specific areas. I am utilizin ...

Text that is aligned vertically and centered within a div container

I need help figuring out how to make a single line of text run vertically and stay centered within its container, both from left to right and top to bottom. Any suggestions on how to achieve this using CSS? ...

The content on the page is not visible when viewing on an Android device in

After spending a considerable amount of time browsing StackOverFlow for coding solutions, I have come across a problem that I can't seem to find an answer for. Yesterday, I made some changes to the media queries on my site in order to incorporate a dr ...

Utilizing Material UI for class-based components

Is there a specific location where I can locate material ui class-based components instead of function-based components? If not, where would be the appropriate place to include the following code in my class component? const classes = useClasses(); const ...