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

Instructions on placing the bottom of an inline-block element flush with the bottom of a block element

In the scenario where I have the following HTML and CSS code: .something{ width: 200px; } .display-block { display: block; } .req-field{ float: right; font-size: 5px; } <div class="something"> <span class="display-block">First name ...

Combining input elements and captchas in one line within Bootstrap

I am currently working on a form group that includes a label, a captcha image, and an input field for the captcha code. My goal is to have the label positioned at the top of the form group, with the captcha image and input field aligned in one line. I have ...

Changing the color of a specific span using Angular

I am working with a dynamic mat-table where columns are added and populated on the fly. The table headers are styled using divs and spans. My goal is to change the color of a header to black when clicked, but also un-toggle any previously selected header. ...

Enhance the appearance of QTreeView items using a customized display delegate and CSS

In my QTreeView, I have a custom delegate set up for one of the columns to display a colored progress bar. The appearance of the progress bar depends on the content and I used the color information from option.palette to mimic the default delegate behavior ...

What is the best way to utilize overflow with TailwindCSS?

1. The Home Component: import React from "react"; import Title from "./Title"; import TaskInput from "./TaskInput"; import TaskList from "./TaskList"; function Home() { return ( <div className="h-scree ...

Unable to align divs horizontally

On my webpage, I have set up two divs - Box1 and Box2. Within Box2, there are two nested divs called Box2-1 and Box2-2. However, when I view the page, Box1 and Box2 do not align side-by-side as expected. Instead, Box1 moves downwards and lines up with the ...

Are there alternative methods to retrieve the CSS properties of web elements more effectively than relying on selenium?

I have a situation in my code where I need to retrieve the CSS properties of a large number of web elements. Currently, I am using Selenium and the code looks like this: ... node = browser.find_element_by_xpath(xpath_to_node) return {k: node.v ...

A custom class that uses toggleClass() does not trigger an alert upon a click event

I am encountering an issue with the toggleClass() function in jQuery that I haven't seen addressed before. Despite successfully toggling the class of one button when clicked, I am unable to trigger a click event on the newly toggled class. Here is th ...

Words not within the span, away from the span border

Iā€™m currently in the process of creating a dedicated section on my website called "Voices of the Nation,ā€ which draws inspiration from the foundations laid out in the U.S. Constitution. The objective is to highlight individuals who have shown their sup ...

What is the purpose of using square brackets in a CSS style declaration?

I've recently taken over the management of a website and I came across some unfamiliar CSS syntax. Has anyone encountered this type of syntax before? Can someone explain what the square brackets inside a style represent? Thank you, Rob .trigger-tx ...

Content in Bootstrap not filling entire mobile screen

The content in this form does not stretch to full screen on mobile phones, but it appears properly on computers and tablets. Please advise on how to solve this issue. https://i.stack.imgur.com/S2XkS.jpg <link rel="stylesheet" href="https://maxcdn.bo ...

Setting a default value in a material-UI select box in React: A step-by-step guide

Utilizing the Select box component from material-ui I aim to have the "select the value" option preselected by default, but prevent the user from being able to select this option after. <FormControl required className={classes.formControl}> <I ...

If the navigation menu contains sub-menus, it should slide to the left

I am currently working on developing a navigation menu with four levels of depth. The menu displays three levels at a time, and when the user reaches the fourth level, the first level should move to the left to make room for the second, third, and fourth l ...

Animating Angular ng-template on open/close state status

I am looking to add animation when the status of my ng-template changes, but I am unable to find any information about this component... This is the code in my report.component.html <ngb-accordion (click)="arrowRotation(i)" (panelChange)="isOpen($even ...

Incorporating and designing a side button using jQuery Mobile

I'm working on adding a button to the left side of the screen that is round (but not necessarily) and partially visible, with a visually appealing design. This button will allow users to open a side menu panel. Below is the HTML code for the button: ...

Samsung devices exclusively showcase background in responsive design

I am encountering a major problem with my website design, specifically with its compatibility on mobile devices. To ensure its responsiveness, I have tested the design on my iPhone, iPad, and Windows Phone. Unfortunately, since I lack an Android device, I ...

Center align the mat-expansion-panel material component in a vertical orientation

When working with the mat-expansion-panel component alongside a mat-accordion, I've encountered an issue where the items are not aligning vertically at the center/middle. I'm unsure of the proper method to achieve vertical alignment for the conte ...

The sticky element should only be active when the visible section is overflowing vertically. There should be no scrollbar if the height is minimal

I'm currently working on a Whatsapp-style navigation bar and facing an issue with the sticky navbar functionality. https://i.stack.imgur.com/Cy3lA.gif Please refer to the details below for more information. To resolve this issue, I have included ...

Search across the entire table in your React application with Global

Having trouble implementing global search with the new Material UI Next table component. I have a handleSearch method that takes an event as a parameter and uses regex to check if the event.target.value matches any data in the table. However, when I dele ...

What could be causing the malfunction of my navbar and carousel functionality?

I am currently facing some challenges with the carousel in my HTML code. I am unable to get it to display images properly. Additionally, there is an issue with the background color of my navigation bar - it doesn't stay at 100% width. Also, when using ...