1
Good people want to add an effect to a div. I’m currently using Hover of css to animate this div, but as everyone knows Hover is activated when the mouse goes over, I wanted to know how I can animate this same div only when it is clicked.
Currently the css code looks like this:
#box{width:280px; height:30px; line-height:30px; background:#0F0}
.area{width:260px; height:0px; background:#000; margin:0px 10px; transition-duration:2s}
.box:hover .area{height:100px;}
That way the div "area" will "grow" when passing the mouse over, only I want it to "grow" only when the div "box" is clicked.
Orion, how do I apply this script? I have to create a name for this script right? only I don’t know how to do anything with jquery
– ivan veloso
You’ll have to put in
head
from your page a call toJquery
(<script src="//code.jquery.com/jquery-1.10.2.js"></script>
. In the link I put, there are examples of complete pages.– Paulo
You did. Straight, just the way I wanted.
– ivan veloso
Just to make it better. I clicked once and the div "grew", now how do I make the div that "grew" decrease if I click on itself again or another div that has the class . box box
– ivan veloso
@Ivanveloso you can put a condition inside the
click
to check if the size of thediv
is 100 or not, and with this assign an animation for each case, if there are doubts it is better to create a new question not to run away from the current topic– Paulo