jquery 将左下角切换到右上角
我已经让这个脚本一切正常,但我想知道是否可以将左下角切换到右上角,
$("a#slick-toggle").click(function() {
$("#slickbox").animate({width: "toggle",
height: "toggle"}, 1000);
});
谢谢 Gareth
i have got this script all works fine but i was wonder if its possible to toggle bottom left to top right
$("a#slick-toggle").click(function() {
$("#slickbox").animate({width: "toggle",
height: "toggle"}, 1000);
});
thank Gareth
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将位置设置为相对位置,然后为
left
属性设置动画,如下所示:您可以在这里尝试一下,它的作用是抓取
.width()< /code>
元素并将其在动画中向左移动那么远,从而产生向右折叠的效果,而不是向左折叠。
.stop(true, true)
部分是为了防止动画队列-up 并且.width()
是执行时的适当值访问它(不是中间动画宽度)。You can set the position as relative then also animate the
left
property, like this:You can give it a try here, what this does is grab the
.width()
of the element and moves it that far to the left in the animation, giving the effect of it collapsing to the right, rather than the left. The.stop(true, true)
portion is to prevent animation queue-up and that.width()
is the appropriate value when going to access it (not a mid-animation width).为此,您可以
浮动
您的#slickbox
到右侧
!JS
HTML
请注意:
float: right
查看演示
In order to do that, you can
float
your#slickbox
toright
!JS
HTML
Please note :
float: right
See Demo
http://api.jquery.com/animate/ 有一个移动示例。右上角可以通过 css 设置为
top: 0px; right: 0px;
所以它会是这样的:http://api.jquery.com/animate/ has an example of movement. Top right can be set via css as
top: 0px; right: 0px;
so it would be something like: