A guide on implementing Flex Direction in React

For my latest project, I decided to create a web page using Cards in React. To achieve this, I utilized React Bootstrap for the card components. However, I encountered an issue with setting the flex property.

Below is a snippet of my component:

import 'bootstrap/dist/css/bootstrap.min.css';
import Card from 'react-bootstrap/Card';
import ListGroup from 'react-bootstrap/ListGroup';
import './Style.css';
import img from  './images/download.jpg'
import Button from 'react-bootstrap/Button';

function MovieList() {
  return (
    <>
    <div id="container">
    <Card style={{ width: '20rem', fontSize: '10px' }} className='box'>
      <Card.Header>
        <Button variant="primary" style={{ width: '6rem', fontSize: '8px' }}>NOW SHOWING</Button>
      </Card.Header>
      ...

And here is the CSS code that I am using:

.container{
display: flex;
flex-direction: row;   
flex-wrap: wrap;
}

Despite trying various methods to apply the flex property in CSS, I still couldn't achieve the desired layout for my web page with cards displayed in rows:

Here is how my current web page looks like: Web Page Example

If you have any suggestions or ideas on how to resolve this issue and display all the cards in a row format, please feel free to share!

Answer №1

In addition to @wouch's response, it is important to note that your

<div id="container">
is using an id attribute which should be targeted in your CSS with #container{} rather than .container{}

Another small issue is that your container div is closed after the first card. If you want to apply flex-direction to both cards, make sure to enclose both cards within the container div.

Appreciate the input.

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

Issue with setState function within setInterval

My current challenge involves updating the value of stateValue with the value of i within a setInterval. However, I am encountering an issue where only the value of i changes and does not update the stateValue as intended within the setInterval. updateV ...

What is the best way to run an npm script with grunt-run?

I currently have a npm task specified in my package.json file for running jest tests: "scripts": { "test-jest": "jest", "jest-coverage": "jest --coverage" }, "jest": { "testEnvironment": "jsdom" }, I would like to run this task using ...

Consistent height constraints within table cells

Trying to create an HTML Email with fixed height blocks? Let's align those blocks! The attached demo shows disproportionate heights and misalignment issues. How can we resolve this problem? DEMO: http://jsfiddle.net/smu0gyx7/ ...

What methods can be used to accomplish this effect using CSS and/or Javascript?

Is there a way to achieve the desired effect using just a single line of text and CSS, instead of multiple heading tags and a CSS class like shown in the image below? Current Code : <h2 class="heading">Hi guys, How can i achieve this effect using j ...

Widget remains static until job triggers data refresh, preventing CSS transition initialization

I am struggling with the html/coffee/scss aspects, although I'm comfortable with Ruby. On my website, I have implemented a hotlist widget sourced from this link: https://gist.github.com/andre-morassut/8705385. While it functions properly, I encounter ...

Enhance your WordPress website with Elementor and choose between React or Angular

I tried searching on Google, but I couldn't find any answers... Is it possible to create a custom Elementor widget in Wordpress using React or Angular? I want to build a component that will pull data from an API and dynamically render the page. I&apo ...

Tips for updating information when a button is chosen

Hello everyone, I need some help with a form that has three select buttons. The button labeled "Distribute" is already selected when the page loads, and it contains information about full name, password, and location. How can I use JavaScript to create a c ...

How do you retrieve specific colored elements from an array using jQuery (or plain JavaScript)?

I am currently in the process of creating interactive checklists. One feature I have implemented is changing the color of a header if all checkboxes associated with it are checked, as shown below: $("input[type='checkbox']").click(function(){ i ...

The Angular 5 animations enter transition successfully performs (void => state) but encounters issues with the leave transition (state => void)

Currently tackling a challenge in Angular 5 where I am trying to build a custom carousel image browser from scratch. The goal is to allow users to navigate through images by clicking or swiping to view the next or previous image. The animations for the :e ...

Is it possible to insert Ruby variables into HAML css using interpolation?

I am in need of a sequence of classes, such as .module1, .module2, ... module(n). My goal is to specify these classes using css, ruby, and HAML: :css .mod1 { background-image: url("#{extra.image}"); } Can I use Ruby variables to streamline ...

Styling and theming in PrimeNG

Seeking advice on how to customize the appearance of the background for the primeNG panel component. I attempted to override the styling using the specific names in my scss file for the component, but it did not work. I also tried inline with <p-panel ...

What is preventing 100% width from filling the entire screen?

My issue involves setting the body with a width of 100% and height as auto. However, the content is not covering the full screen and an extra scrollbar is appearing from left to right. For the complete code and results, please visit the following links: ...

Organizing DIV elements with Bootstrap 4 while avoiding the use of additional DIVs

Organizing DIV elements using the bootstrap grid system is usually simple, but there are times when I struggle with it. https://i.sstatic.net/qH08J.jpg I believe creating this grid design should not be too difficult and can be accomplished without any ad ...

Where can I locate the definition of a div in WordPress?

Recently, I installed a new template on my WordPress blog. However, the template designer added a footer copyright that I am unable to delete. It seems like the copyright text is not located in any of the PHP or CSS files. Upon inspecting the elements, I f ...

Having trouble toggling journal entries in an HTML journal? The Jquery function might not be working properly

I have been tasked with creating a civil war journal for my 8th grade Social Studies class and I decided to present it as an HTML file featuring the title and date of each journal entry. The goal is to allow users to click on each entry to open it while au ...

Tips for customizing stepper color using hooks in Material UI

Looking for help to change the color of a stepper from 'primary' to 'success' using React hooks. The stepper component does not have a built-in color method like an icon, so I'm struggling to find a solution. Any advice would be gr ...

An always-visible navigation menu

After exploring various resources related to the same topic, such as sticky navigation bars and others, I noticed that all the solutions provided involved the use of this link http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js. However, inc ...

Is the pre-building of pages in React/Next.js causing a slowdown in the application?

I recently embarked on studying the Next.js framework and came across a question. Consider a scenario where I have a dynamic route for users like users/profile/[id].js. If I attempt to pre-build them with Static generation, wouldn't this potentially ...

What is the best method for determining the file size of multiple URLs?

I am utilizing npm's url-file-size package in Node.js to retrieve the file size. My goal is to obtain the file sizes of an array of URLs, like so: let arrayUrls = [ 'https://cdn.shopify.com/s/files/1/0597/0149/3909/files/image_6b47157f-0e00- ...

Creating a multi-tiered cascading menu in a web form: Harnessing the power of

In my form, there is a field called 'Protein Change' that includes a multi-level dropdown. Currently, when a user selects an option from the dropdown (for example, CNV->Deletion), the selection should be shown in the field. However, this funct ...