I am developing a blogging website and here is my reactJS code and i am unable to display the card components horizontally.
App.js
import React from 'react';
import './App.css';
import Card from './components/Card';
import dp from './images/dp.jpeg';
export default function App() {
return(
<div className='App'>
<center> <h1> Data Structure and Algorithms</h1></center>
<div className='card-cont'>
<Card
title='Dynamic Programming'
imageUrl={dp}
body='Dynamic programming is both a mathematical optimization method and an algorithmic paradigm. '
/>
<Card
title='Dynamic Programming'
imageUrl={dp}
body='Dynamic programming is both a mathematical optimization method and an algorithmic paradigm. '
/>
</div>
</div>
)
};
App.css
.card-cont {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
3
Answers
I would add flex direction to specify you want a row display.
If that doesn’t fix the issue, I would also specify the widths of each Card to ensure they are not taking up 100% of the width in the row.
can you try the following css change?
remove
flex-wrap: wrap;
and let me know if anyThe problem is the combination of using
flex-wrap: wrap
on the parent together withwidth: 100%
in the children.Here a sample based on your component to show the issue: