I have an image that I want to enhance with some effects. I was able to add a hover overlay using a div
. Now, I am looking to add an onclick
event to change to another overlay div
.
Below is the code I have so far, or you can view the CodePen Here
<div id="box">
<div id="overlay">
<span id="plus">+</span>
</div>
CSS:
body { background:#e7e7e7;}
#box { width:300px;
height:200px;
float: left;
box-shadow:inset 1px 1px 40px 0 rgba(0,0,0,.45);
border-bottom:2px solid #fff;
border-right:2px solid #fff;
margin:5% auto 0 auto;
background:url(http://ianfarb.com/wp-content/uploads/2013/10/nicholas-hodag.jpg);
background-size:cover;
border-radius:5px;
overflow:hidden;}
#overlay { background:rgba(0,0,0,.75);
text-align:center;
padding:45px 0 66px 0;
opacity:0;
-webkit-transition: opacity .25s ease;}
#box:hover #overlay {
opacity:1;}
#plus { font-family:Helvetica;
font-weight:900;
color:rgba(255,255,255,.85);
font-size:96px; }
Currently, I have only implemented a hover effect. When the image is clicked, I want to change the plus symbol (+) to a minus symbol (-) and display a small div at the bottom of the image with a brief description.
Upon triggering the second overlay div
, clicking the minus symbol should revert back. I will provide an image below to illustrate what I am trying to achieve.
In the image below, you can see the blue div
that should appear upon the onclick
event.