admin管理员组文章数量:1391981
I am trying to make an image hidden hidden using jQuery. I am using .hide()
function. I am applying it to div containing the image which has to be hidden.
Its not working for some reason. I have created a fiddle.
Is it possible to use animate
so that the image bees visible from right to left in say 1 sec. In other words, animate the width from 0 to maximum value but the image should bee visible from left to right.
I am trying to make an image hidden hidden using jQuery. I am using .hide()
function. I am applying it to div containing the image which has to be hidden.
Its not working for some reason. I have created a fiddle.
Is it possible to use animate
so that the image bees visible from right to left in say 1 sec. In other words, animate the width from 0 to maximum value but the image should bee visible from left to right.
4 Answers
Reset to default 2You were not using the correct syntax.missing ); at the end of each function
$(document).ready(function() {
$('#animate').click(function() {
$('#myimage').animate({width: 'hide'},1000);
});
});
You can find the working jsFiddle here.
Couple of points:
- In your original fiddle, you forgot to use the terminating
)
- that's why the hiding did not work. - To acplish the animation, I've used the blind jQuery easing. To use this (and other easings), you need to reference the jQuery UI library (as I am doing in the fiddle). Took me a while to figure out why the effect does not work till I ticked that little checkbox on the left :)
Just for the record, I am also posting the code from the fiddle:
$(document).ready(function() {
$('#animate').click(function() {
$('#myimage').toggle('blind', { direction: 'horizontal' }, 1000);
});
});
Here is what you want :
http://jsfiddle/rAqcP/27/
Please change the animations as you need.
~K
I don't think you should animate the width because the image will look weird when resized.
You can achieve what you want like this:
- set the container (the DIV#myimage) to
overflow: hidden
andposition: relative
: hiding the overflow will allow to move the image to the left out of the container - set the image to
position: absolute
and move the image to the left to hide it - animate the
left
property back to zero
DEMO
DEMO (initial state with css)
本文标签: javascriptjQuery animationmaking an image visible from left to rightStack Overflow
版权声明:本文标题:javascript - jQuery animation - making an image visible from left to right - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744743684a2622761.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论