I have a problem for override CSS style on element that has class.
I'm using keyframe animation CSS class.
Check this fiddle out for live action :
HTML :
<div id="sidebar" class="animation">this is sidebar</div>
<div id="trigger">this is trigger</div>
CSS :
#sidebar {width:225px; height:100%; background:red; position:fixed; top:0; left:0; display:none; }
#trigger {float:right; }
.animation {animation-duration: 0.5s; animation-fill-mode: both; }
@keyframes slideInLeft {
from {
transform: translate3d(-100%, 0, 0);
}
to {
transform: translate3d(0, 0, 0);
}
}
.slideInLeft {
animation-name:slideInLeft;
display:block !important;
}
JS :
$(document).ready(function() {
$("#trigger").on("click", function() { // trigger for opening #sidebar
$("#sidebar").addClass("slideInLeft"); // addClass, so it animated
});
$("#sidebar").on("mousemove", function(e) { // move #sidebar according mousemove
e.preventDefault(); // reset default behavior
$(this).css("transform", "translate3D(" + e.pageX + "px, 0, 0)")
// add style for move #sidebar, look at this element, not working. what's wrong here?
});
});
Why #sidebar not moving? the CSS style already add to it. but not moving.
What's wrong with my code?
thanks in advance...