I have a group of boxes with a hover effect and I want the individual boxes to be flipped only when clicked.
I am trying to remove this block of css:
/*.flip-container:hover .flipper {
transform: rotateY(180deg);
}*/
And use underscorejs to add it back only when clicked but not working:
window.onload = function(){
var memoryCards = document.getElementsByClassName("flipper");
_.each(memoryCards, function (card){
this.addEventListener("click", function(){
this.setAttribute("transform", "rotateY(180deg");
}
);});
};
Here is my current code that flips on hover:
<div class="flip-container" >
<div class="col-xs-3 box-size flipper" >
<div class="front"></div>
<div class="back"></div>
</div>
</div>
.box-size {
height: 100px;
width: 100px;
border: 1px solid black;
position: relative;
}
.flip-container.hover .flipper, .flip-container.flip .flipper {
transform: rotateY(180deg);
}
*.flip-container:hover .flipper {
transform: rotateY(180deg);
}*
/* flip speed goes here */
.flipper {
transition: 2.0s;
transform-style: preserve-3d;
position: relative;
}
/* front pane, placed above back */
.front {
/*z-index: 2;*/
/* for firefox 31 */
transform: rotateY(0deg);
background-color: green;
position: absolute;
top: 0;
width: 100%;
margin-left: -15px;
height: 100px;
}
.back {
transform: rotateY(180deg);
background-color: red;
position: absolute;
top: 0;
width: 100%;
height: 100px;
margin-left: -15px;
}
Try this simple code..with css
or go to this Fiddle code
I use
HTML Part
css part