I have a few cards that all have different-colored background linear gradients. On mouse over, I want to overlay a semi-opaque white background so I can put some popup text, while preserving the original gradient underneath. How can I accomplish this in an automated way?
I don't want to do the brute force way: add a :hover in each individual card's CSS and add a second linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3)) after the initial linear-gradient(actual card color).
I'd like to use jQuery, but I can't get it to append to the background property. It only replaces with a new value.
Fiddle here or code below:
<div class="card card--1">
<p>
Some text
</p>
</div>
<div class="card card--2">
<p>
More text
</p>
</div>
<div class="card card--3">
<p>
Even more text
</p>
</div>
.card {
height: 50px;
border-radius: 15px;
position: relative;
transition: 0.1s all;
transform: translateY(0px);
text-align: center;
&--1 {
background: linear-gradient(0deg, #ffd66e, #ffeab2, #c8f8ff 80%);
}
&--2 {
background: linear-gradient(11deg, #f5ac9c, #ffefe3);
}
&--3 {
background: linear-gradient(18deg, #693b10, #fff5d3);
}
}
$(document).ready(function() {
$(".card").mouseenter(function() {
$(this).css("background", "linear-gradient(0deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.3))")
})
});