I want to create a Card
component in React and CSS that already has a shadow, but on hover it gets shadow-er.
I added box-shadow
to the container css but it seems to be applied only to its children.
Is there a way to shadow only the card-container and not its children?
For example on hover the two p
elements get their own shadow, which I don't want.
this is the card structure in card render function
<div className={"card-container"}>
<div className="card-title">{this.state.title}</div>
<div className="card-children">{this.state.children}</div>
<div className="card-body">
<p> text line one </p>
<p> text line two </p>
</div>
</div>
and this is the card css
.card-container {
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); /* Card look */
transition: 0.3s;
background-color: white;
border-radius: 4px; /* Round corners */
border-left: 5px solid #5f37ff; /* Blue left border */
}
.card-container:hover {
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
}