I have a row of reactstrap cards that are dynamically placed in rows, and for "md" screen sizes and up (bootstrap), there will be 3 cards per row, and for lower it'll be 2 cards.
Here's the component:
<Card
outline
as='a'
style={{ cursor: 'pointer', margin: '1rem' }}
>
<CardImg top width='100%' src={img}' />
<CardBody>
<CardTitle tag='h5'>{this.props.title}</CardTitle>
</CardBody>
</Card>
My problem is, I want only the middle card to have margins on the sides (marginLeft: '1rem', marginRight: '1rem').
Since the number of cards in a row changes based on screensize, I can't just say "if it's a multiple of x, then have this style". Unless I know the screensize, so is there a way to create a prop in my parent component that I can pass into my card component to let it know what to set the margin as?
Thanks
(Any better suggestions are welcome)
More code:
render () {
return (
...
<div className='row' style={{margin:'0rem'}}>
{
disp.map((d, index) => {
return (
<div className='col-md-4 col-6 d-flex'>
<the card component here>
</div
)
...
}
}
</div>
....