我已经得到了这个脚本一切正常,但我想知道是否有可能切换左下角右上角
$("a#slick-toggle").click(function() {
$("#slickbox").animate({width: "toggle",
height: "toggle"}, 1000);
});感谢Gareth
发布于 2010-08-31 22:26:49
http://api.jquery.com/animate/有一个运动的例子。右上角可以通过css设置为top: 0px; right: 0px;,因此它将类似于:
.animate({
top: 0,
right: 0,
height: 'toggle'
});发布于 2010-08-31 22:32:31
您可以将位置设置为相对位置,然后还可以设置left属性的动画,如下所示:
$("a#slick-toggle").click(function() {
var sb = $("#slickbox").stop(true, true), w = sb.is(":visible") ? sb.width():0;
sb.animate({width: "toggle", height: "toggle", left: w}, 1000);
});You can give it a try here,这样做的目的是获取元素的.width(),并将其移动到动画中的左侧,从而产生向右而不是向左折叠的效果。.stop(true, true)部分是为了防止动画排队,且当要访问它时,.width()是适当值(不是动画中间宽度)。
发布于 2010-08-31 22:34:33
为了做到这一点,你可以 float你的#slickbox到right!
JS
$(document).ready(function() {
$("a#slick-toggle").click(function() {
$("#slickbox").animate({width: "toggle",
height: "toggle"}, 1000);
return false;
});
});HTML请注意:float: right
<a href="#" id="slick-toggle">Clicked</a><br />
<div style="width: 25px; float: left;">
<div id="slickbox" style="float: right;">Testt</div>
</div>See Demo
https://stackoverflow.com/questions/3609919
复制相似问题