I've been attempting to make all three cards reveal text upon hovering over them with the mouse pointer. However, I'm facing an issue where only the text in the first card on the left is displayed, while the other two cards remain unaffected, despite having added lorem ipsum text to all three divs for the cards.
I've scoured the internet for solutions but haven't come across anything that resolves this specific problem. It seems like I may need to incorporate a JavaScript loop to iterate through it, but I'm struggling to figure out how to implement this.
HTML
<div class="wrapper">
<div class="card" id='card'>
<div class="orangeCover">
<p id="hidden" class='easein'>Lorem ipsum dolor sit amet,
consectetur adipisicing elit. Ipsa, eaque.
</p>
</div>
</div>
<div class="card" id='card'>
<div class="orangeCover">
<p id="hidden" class='easein'>Lorem ipsum dolor sit amet,
consectetur adipisicing elit. Ipsa, eaque.
</p>
</div>
</div>
<div class="card" id='card'>
<div class="orangeCover">
<p id="hidden" class='easein'>Lorem ipsum dolor sit amet,
consectetur adipisicing elit. Ipsa, eaque.
</p>
</div>
</div>
</div>
CSS
html,
body {
margin: 0;
}
.wrapper {
width: 100vw;
height: 100vh;
overflow: hidden;
display: grid;
grid-column-gap: 20px;
grid-row-gap: 20px;
grid-template-columns: auto auto auto auto;
}
.orangeCover {
width: 250px;
height: 250px;
position: absolute;
}
.orangeCover:hover {
background-color: orangered;
transition: ease-in 0.5s;
}
.card {
border: 2px orangered solid;
width: 250px;
height: 250px;
margin-left: 100px;
margin-top: 100px;
background-image: url("http://source.unsplash.com/random/250x250");
}
#hidden {
visibility: hidden;
}
.reveal {
margin-left: 20px;
color: white;
font-size: 1.5rem;
}
Javascript
let text = document.querySelector("#hidden"), i;
let overlay = document.querySelector(".card");
let hiddenOverlay = document.querySelector(".card");
overlay.addEventListener("mouseover", newOverlay);
hiddenOverlay.addEventListener("mouseleave", hidden);
function newOverlay() {
text.style.visibility = "visible";
text.className = "reveal";
}
function hidden() {
text.style.visibility = "hidden";
}