Reputation: 531
I have a small css issue in my react app, but I can't find a way to fix it.
The background of my div is always white no matter the color I set (Hex, rgb or rgba). Even the border-radius is not working but width/height and margins are working perfectly fine.
Here's my code :
card.js
import React from "react";
import "../styles/card.css";
export default class Cards extends React.Component {
render() {
return (
<div className="card">
<img src="../images/cards/BR-Customcard-back.png" alt="card" />
<span>Card Name</span>
</div>
);
}
}
card.css :
.card {
background-color: rgba(107, 66, 30, 0.4);
width: 282px;
height: 417px;
margin: 10px auto 10px auto;
text-align: center;
border-radius: 20px;
}
Parent element, cards.js :
import React from "react";
import "../styles/cards.css";
import Card from "./Card";
export default class Cards extends React.Component {
render() {
return (
<div className="cards" style={{ padding: "10px" }}>
<Card />
<Card />
<Card />
</div>
);
}
}
cards.css
.cards {
width: 100%;
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
rendered css :
.card {
position: relative;
display: -ms-flexbox;
display: flex;
-ms-flex-direction: column;
flex-direction: column;
min-width: 0;
word-wrap: break-word;
background-color: #fff;
background-clip: border-box;
border: 1px solid rgba(0,0,0,.125);
border-radius: .25rem;
}
.card {
background-color: rgba(107, 66, 30, 0.4);
width: 282px;
height: 417px;
margin: 10px auto 10px auto;
text-align: center;
border-radius: 20px;
}
rendered markup :
<div class="cards">
<div class="card">
<img src="../images/cards/BR-Customcard-back.png" alt="card">
<span>Card Name</span>
</div>
....
</div>
Upvotes: 0
Views: 2385
Reputation: 531
Found the issue, I'm using the card class which is already defined in react or bootstrap. I renamed my class customCard and it's working.
Thanks for the help
Upvotes: 0
Reputation: 43
The class name you set on the component is not the same class name as you defined in the CSS file; it should be:
className="card"
Upvotes: 3