On the desktop view, everything is working as expected except for the DIV that appears on hover. It doesn't show in mobile view. I would like to make it appear on touch/click on mobile or tablet devices.
I have tried using :active
after :hover
based on some suggestions, but that did not work.
I am open to solutions involving JavaScript or jQuery as well.
DEMO: https://jsfiddle.net/ovg6xzhu/
HTML:
<div class="hoverEffect hoverEffect-first">
<img src="https://via.placeholder.com/150" />
<div class="mask">
<h2>Web Services!</h2>
<p>We are going to build another sets of css hover image effects with CSS3 animations.<br /><a href="#">View All</a></p>
</div>
</div>
CSS:
.hoverEffect {
width: 100%;
float: left;
overflow: hidden;
position: relative;
text-align: center;
cursor: default;
border-radius: 2px;
margin-bottom: 30px;
}
.hoverEffect .mask {
width: 100%;
position: absolute;
overflow: hidden;
top: 0;
left: 0
}
.hoverEffect img {
display: block;
position: relative
}
.hoverEffect h2 {
text-transform: uppercase;
color: #fff;
text-align: center;
position: relative;
padding: 10px;
margin: 20px 0 0 0
}
.hoverEffect p {
position: relative;
color: #fff;
padding: 0px 20px 20px;
text-align: center
}
.hoverEffect-first img {
transition: all 0.2s linear;
width:100%;
height:auto;
}
.hoverEffect-first .mask {
opacity: 0;
background-color: rgba(61, 90, 128, 0.95);
transition: all 0.4s ease-in-out;
width: 100%;
height: 100%;
}
.hoverEffect-first h2 {
margin: 10px 40px;
transform: translateY(-100px);
opacity: 0;
transition: all 0.2s ease-in-out;
}
.hoverEffect-first p {
transform: translateY(100px);
opacity: 0;
transition: all 0.2s linear;
}
.hoverEffect-first:hover img, .hoverEffect-first:active img {
transform: scale(1.1);
}
.hoverEffect-first:hover .mask, .hoverEffect-first:active .mask {
opacity: 1;
}
.hoverEffect-first:hover h2,
.hoverEffect-first:hover p,
.hoverEffect-first:active h2,
.hoverEffect-first:active p {
opacity: 1;
transform: translateY(0px);
}
.hoverEffect-first:hover p, .hoverEffect-first:active p {
transition-delay: 0.1s;
}
.hoverEffect-first:hover a.info, .hoverEffect-first:active a.info {
transition-delay: 0.2s;
}