Tips for perfectly aligning all elements in a row within a card design

Hi there, I'm trying to figure out how to align the content of this card in a single row instead of stacked on top of each other. Here's the code snippet:

<div class="container">
            <form onSubmit={submitHandler}>
                <div class="row" style={{ width: "300px", marginTop: "40px", marginLeft: "70px", height: "450px" }}>
                    <FormControl variant="outlined">
                        <InputLabel id="demo-simple-select-outlined-label" >Choose Module Type</InputLabel>
                        <Select style={{ marginBottom:"20px"}}
                            name="name"
                            labelId="demo-simple-select-outlined-label"
                            id="demo-simple-select-outlined"
                            onChange={handleDropdownChange}
                            label="TypeList"
                        >
                            {
                                dropdown.map(options =>
                                    <MenuItem value={options["moduleType"]} >{options["moduleType"]}</MenuItem>
                                )}
                        </Select>
                        <TextField 
                            style={{ marginTop: "10px", marginBottom:"20px" }}
                            id="outlined-helperText"
                            label="Module Name"
                            onChange={handleChangeModuleName}
                            variant="outlined"
                        />
                        <TextField
                            style={{ marginTop: "20px" }}
                            id="outlined-helperText"
                            label="Course Duration"
                            onChange={handleChangeDuration}
                            variant="outlined"
                        />
                        <div style={{ margin: "auto", marginTop: "20px" }}>
                        <Button type="submit" variant="contained" color="primary">ADD</Button>
                      </div>
                    </FormControl>
                </div>
            </form>
         </div>

I'd appreciate any help or tips on how to achieve this layout. Thank you :)

Answer №1

The concept of flex containers is to either expand items to occupy available free space or shrink them to prevent overflow. One key feature of flexbox layout is its direction-agnostic nature, unlike traditional layouts such as block (vertically-based) and inline (horizontally-based).

Consider using display: flex; to keep all items in a row.

.row {
    display: flex;
}

Answer №2

Experiment with incorporating the flex property into your design. To do this in your css stylesheet, include the following code:

.row {
    display: flex;
}

It is recommended to avoid inline styles (where you apply css properties directly within your html file). Instead, utilize an external stylesheet (such as style.css). Link it to your html file by adding this line of code:

<link rel="stylesheet" type="text/css" href="/style.css">

Answer №3

To make your row class flexbox enabled, just include display:'flex' in the CSS

.row{
     display:'flex'
 }

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

Parent div not properly adjusting its height

I am currently working on developing a fluid layout, however I have encountered a minor issue with the height of the container. The outer <div> (highlighted in yellow, ip_A-1) is not adjusting its height according to its child elements. You can view ...

How to style the videojs chapter menu with CSS to extend the box to the full length of the line

I am currently working on customizing the videojs CSS for the ChapterButton menu in order to make it expand to accommodate varying line lengths without wrapping. Even though I can set it to a fixed width, I require it to be able to adjust to different line ...

Utilizing React Router DOM 6.3.0 to read the pathname from an undefined source

I am currently using react-router-dom version 6.3.0 and have set up the following routes inside my App component <BrowserRouter> <Routes> <Route path='/article/*' element={<Article />} /> </Routes> </Brows ...

`Can we add a condition to extend a class name in React?`

I'm trying to modify a div's class name based on certain conditions. Here's what I have so far: className={`orignClassName ${this.state.something === 'something' ? 'extendClassName1' : 'ExtendClassNam ...

What might be the reason behind the failure to implement my color class on the text within the <p> element?

I'm looking to streamline my stylesheet to easily change the color of different text elements. I've created a list of general colors that can be applied using classes, like (class="blue") . Here are some examples: .dark-grey { color: #232323; } ...

"Encountered an error: Expo command not recognized on Mac operating system

As I dive into the world of react native and embark on my initial project, I encounter an issue while installing the expo cli. After what appears to be a successful installation, I receive this message: + <a href="/cdn-cgi/l/email-protection" class="__c ...

best practices for creating space between flexbox items

My task involves presenting a continuous scroll list of scheduled jobs using Angular Material. Each item in the list needs to be divided into three columns utilizing flexbox. Despite my efforts, I am struggling with adding space between the columns within ...

Vertically and horizontally align an SVG within 2 divs without modifying the parent div of the SVG

Is there a way to center an SVG both vertically and horizontally inside a div? The issue is that the width and height of the SVG are determined using the vx-responsive library, resulting in the following DOM structure: Edit: code has been added below < ...

Axios - transforming HTTP cookies into authorization headers for enhanced security

My application's authentication system is based on using access and refresh tokens. When a user logs in, the API generates three important components: A refresh token An access token string with headers and payload An acce ...

React Router throwing an error about an Invalid Hook Call when attempting to use useState in index.tsx instead of App.js

I'm currently learning React Router by following a video tutorial, but I've run into an issue. In my Stackblitz project, there is no App.js file, so I've placed everything inside index.tsx. However, now I need to use the line ----> const ...

Error message indicating that the event "OnkeyDown" is not in sync within the React application

Hey everyone! I'm a beginner in web development and I'm struggling to understand why the event "OnKeyDown" is triggered the second time. My task involves changing (increasing, decreasing) parts of a date (day, month, year, hour, minutes, seconds) ...

Activate SVG graphics upon entering the window (scroll)

Can anyone assist me with a challenging issue? I have numerous SVG graphics on certain pages of my website that start playing when the page loads. However, since many of them are located below the fold, I would like them to only begin playing (and play onc ...

Changing states in next.js is not accomplished by using setState

Struggling to update the page number using setCurrentPage(page) - clicking the button doesn't trigger any state change. Tried various methods without success. Manually modified the number in useState(1) and confirmed that the page did switch. import ...

What are some potential causes of webpack-dev-server's hot reload feature not working properly?

Having an issue with my React project. When I try to use hot reload by running "npm start" or "yarn start" with webpack-dev-server configured (--hot flag), I'm getting the error message: [error message here]. Can anyone assist me in troubleshooting th ...

Is all of the CSS stored in one or multiple files?

Will the number of CSS files on my website impact its performance? I understand the necessity of having a separate file for print styles, but I'm wondering about the other CSS files. Is it better to have all my styles in one file or split them into mu ...

React has disabled the input, causing SCSS to struggle to interpret the data

There is a React component with a checkbox that becomes disabled under certain conditions. The disabled function in React is functioning correctly, but the SCSS is unable to apply the disabled properties because the disabled attribute is not rendered in t ...

What is the process for linking my HTML page to my CSS stylesheet?

This is similar to what I have in the content of my HTML page. <link rel="stylesheet" type="text/css" href="/untitled2.css"> I thought this was right, but it doesn't seem to be functioning. Any ideas on what might be wrong? ...

What is the best way to position the publication date of an article at the bottom of the

I am looking to have the article publishing date (1/9/2016) positioned at the bottom inside the container. Right now, the date appears just below the text, but I want it to be aligned at the bottom of the container. The website in question is watchathletic ...

Running yarn build in react results in CSS modifications

When working in my local development environment, I have everything functioning as intended. However, after executing yarn build, all of my styles appear drastically different. The project was set up using create-react-app and styled with regular CSS. Bel ...

Using Rails to reference an image in CSS

My application on Heroku, built with Rails, features a striking image as the background on the landing page. Since Heroku's file system is read-only, I made the decision to store these images (selected randomly) on AWS S3. In my .css(.scss) code, the ...