How do I keep an element scaled in CSS3 in-till mouseleave? Then on mouseleave scale the element back to it's original size
Tags: jquery,css3,animation,hover,scale
Problem :
When I use mouseenter on a button I want the scale command in CSS3 animation to be triggered on a separate element.
My code currently does this, however I need the scale to stay at it's finished point in-till mouseremove, then the element that's scaled needs to scale back to initial dimensions.
How do I do this?
Here's my code:
$("#button").mouseenter(function() {
$('.transform').toggleClass('classname');
});
CSS:
.transform {
-webkit-transition: all 2s ease;
-moz-transition: all 2s ease;
-o-transition: all 2s ease;
-ms-transition: all 2s ease;
transition: all 2s ease;
}
.classname {
-webkit-animation: cssAnimation 1.000s 1 ease;
-moz-animation: cssAnimation 1.000s 1 ease;
-o-animation: cssAnimation 1.000s 1 ease;
}
@-webkit-keyframes cssAnimation {
from { -webkit-transform: scale(1.000) }
to { -webkit-transform: scale(0.800) }
}
Thank you.
Solution :
Use the .hover()
event handler instead.
change mouseenter
to hover
$("#button").hover(function() {
$('.transform').toggleClass('classname');
});
Which is the same as
$("#button").on('mouseenter mouseleave', function() {
$('.transform').toggleClass('classname');
});
The first part was based on how to remove the class..
But you do not need to use animations for the scaling.. just transitions will do.
And since transition go both ways by default it will handle the scale up automatically once you remove the class.
Demo at http://jsfiddle.net/3tsuS/
CSS Howto..
Add two class for up and down arrows and toggle the class inside the heading click function. <div class="option-heading"> <div class="arrow-up">▲</div> <div class="arrow-down">▼</div> heading 1 </div> <div class="option-content"> <p>content 1</p>...
here is a little example how you can show/hide an element on page scroll with jQuery. hope this helps: http://jsfiddle.net/KWyS2/ <script type="text/javascript"> $(document).ready(function(){ $(window).scroll(function(){ var scrollTop = $(window).scrollTop(); $('.addDistance').html(scrollTop); if(scrollTop...
Set position:fixed to the footter header { width: 100%; background-color: #000000; height: 8%; min-height: 8%; z-index:1000; position:fixed; /*.........^........*/ top:0; } footer{ bottom: 0; background-color: #000000; z-index:1000; width: 100%; height: 6%;...
Like this (CSS) if you want to target the specific element with class .email: .icons .email:hover { // Your code here opacity: .5; } If you want a more generic...
Added a generally accepted version of clearfix, and removed a lot of positioning. The big thing is your widths were 15% + 85% = 100% + 3px for border, so...
You should be able to set the top and bottom values of the aside. Something like: aside { position: relative; float:left; width:170px; top: 0px; bottom: 0px; } ...
I set this up on my computer and it worked fine. After looking at your example page, the problem is because you've set the image to display:block. Either remove that...
Try this. #hero { float: left; } img { display: block; float: right; } ...
When you hiding elemment, its still there (just hidden), so thats why you have this problem. Ill suggest you to create simple script against css :nth-of-type(even) selectors. First, two clases:...
Many different approaches didn't give any appropriate results. The solution was the following: uninstall Windows 8, install Windows 7 and disable multi-touch gestures. ...
CSS used by SourceBits: body { background: #8D9698 url('../images/body-by-bg.jpg') repeat fixed 0 0; } SourceBits background link: http://www.sourcebits.com/images/body-by-bg.jpg CSS used by YouTube: body { background: no-repeat url(//s.ytimg.com/yt/imgbin/www-refreshbg-vflC3wnbM.png) 0 0; background-color:...
You could check to see if any of the keys in $_GET intersect with $active_links: $active_links = array("home","html","css","jquery","php","sql","psd"); if(array_intersect($active_links, array_keys($_GET))){ ?> class="active"<?php } ...
Ok so I can't post comments yet but I've run into a similar problem before. Without any additional code I can make an assumption that x is the calculated value...
Add a span in the page where you want the buttons to be <span id='slideselector'></span> in the ready function, add an index attribute to each .imgLike div and a corresponding...
After reading the LESS CSS website, you need to change the order of your equation The output is pretty much what you expect—LESS understands the difference between colors and units....
This wont work as you have not defined the /style.css route in your node app. You can approach this in two ways. Embed the css directly in your html file....
What is meant by rendering? how it is done (with regard to CSS)? I'd say "rendering" roughly equals taking instructions about what should be and materializing it into something...
You can simplify this greatly. You don't necessarily need to use the grid but can (use col-*-12 or col-*-4 col-*-offset-4). And you only need one div and two rules to...
Assuming that you will have just two a, you can do something like this to remove the last one (the second one) .inner a:last-child{display:none} unfortunately i don't know hot to...
Why don't you try ui tooltip class ? Try: .ui-tooltip { background-color:#FF9999; width:500px; font-weight:normal; font-size:75%; color:#FF3300; z-index: 9999; } OR try with .ui-tooltip.tooltip_model_and_plans{}...
There are two ways using which you can create a banner image, the easy way and the not-so-difficult way. The Easy Way: Create a banner image using an image editing...
Put the grid-view and update progress html within a wrapper div. Position div relatively and position the update progress absolutely at center. See this jsfiddle that I have set up:...
It's not working because you're not actually targeting the anchor tag in your second style declaration. Try: #page #list a { color: #fff; /* white */ } This won't change...
I can say i managed to do exactly what you are asking for, however it's not that neat! in fact i modified on the extension code (i don't know if...
You can use :pseudo elements use skew for the ribbons box-shadow for the inner circle .medal { width: 100px; height: 120px; } .ribbon { width: 80px; height: 70px; margin: 0...
I'm attaching full code (using your cart.php without changes). You can test it out on the fiddle also. <!DOCTYPE html> <html> <head> <title>Test show()</title> <script src="http://code.jquery.com/jquery-1.10.2.min.js" type="text/javascript"></script> <script>...
You should use JQuery Timepicker for this problem. One line of code will fix your problem. You can download it and read the documentation on it here http://jonthornton.github.io/jquery-timepicker/ For example...
You can have CSS only solution for this, there is no need to have a javscript for this you can try adjacent siblings selectors of CSS: To target very next...
I am not exactly sure what you code is doing, but if you want to get a jQuery object out of a Raphael object then do this: var $jQueryObject =...
Instead of using top, try using bottom:100%. You can use margin-top to fine-tune this alignment, say by a few pixels.