I just started my first React project and I'm facing issues with CSS. I'm trying to make a card with a hover effect on it, ofund a nice one online but it ised nested css, I tried node-sass but didn't really worked. I converted the CSS code to plain CSS but I can't figure out the hover effects in the card!!
`
card:
<section >
<a href="#" >
<h3>01</h3>
<h4>Portfolio Site.</h4>
<p>My personal site using ReactJs.</p>
</a>
</section>
Card CSS: I know it's a mess!! sorry...
.page-contain {
display: flex;
min-height: 100vh;
align-items: center;
justify-content: center;
background: #e7f3f1;
border: 0.75em solid white;
padding: 2em;
font-family: "Open Sans", sans-serif;
}
.data-card {
display: flex;
flex-direction: column;
max-width: 20.75em;
min-height: 20.75em;
overflow: hidden;
border-radius: 0.5em;
text-decoration: none;
background: white;
margin: 1em;
padding: 2.75em 2.5em;
box-shadow: 0 1.5em 2.5em -0.5em rgba(#000000, 0.1);
transition: transform 0.45s ease, background 0.45s ease;
}
.data-card h3 {
color: #2e3c40;
font-size: 3.5em;
font-weight: 600;
line-height: 1;
padding-bottom: 0.5em;
margin: 0 0 0.142857143em;
border-bottom: 2px solid #753bbd;
transition: color 0.45s ease, border 0.45s ease;
}
.data-card h4 {
color: #627084;
text-transform: uppercase;
font-size: 1.125em;
font-weight: 700;
line-height: 1;
letter-spacing: 0.1em;
margin: 0 0 1.777777778em;
transition: color 0.45s ease;
}
.data-card p {
opacity: 0;
color: #ffffff;
font-weight: 600;
line-height: 1.8;
margin: 0 0 1.25em;
transform: translateY(-1em);
transition: opacity 0.45s ease, transform 0.5s ease-in;
}
.data-card .link-text {
display: block;
color: #753bbd;
font-size: 1.125em;
font-weight: 600;
line-height: 1.2;
margin: auto 0 0;
transition: color 0.45s ease-in;
}
.data-card:hover {
background: #753bbd;
transform: scale(1.02);
}
.data-card h3:hover {
color: #ffffff;
border-bottom-color: #a754c4;
}
.data-card h4:hover {
color: #ffffff;
}
.data-card p:hover {
opacity: 1;
transform: none;
}
.data-card .link-text:hover {
color: #ffffff;
}
`
I want to apply the hover effects to all tags in the card section (.page-contain) when I hover over it, right now I have to hover on individual elements for them to act in hover state!!
CodePudding user response:
This selector .data-card h3:hover
means: if I hover on h3, this and this should happen.
What you want is this .data-card:hover h3
which means: when I hover on data-card, the h3 should look like this and that.
You should change other selectors similarly.