【发布时间】:2014-04-26 03:32:28
【问题描述】:
我正在使用“切换”幻灯片效果,并希望显示 div 的一部分,用户可以单击该部分来显示整个 div。我现在的解决方案的问题是#click_here 在触发“切换”时从左向右跳转。我想找到一个解决方案,当触发“切换”时,#click_here 随着幻灯片动画从左到右逐渐移动。
到目前为止,这是我的 jQuery 脚本:
$('#click_here').click(function() {
var effect = 'slide';
var options = { direction: 'left' };
var duration = 700;
$('#info_box').toggle(effect, options, duration);
return false;
});
这是我的html
<div id="wrap">
<div id="click_here">
<p>Click here!</p>
</div>
<div id="info_box">
<h1>Here is some cool info!</h1>
</div>
</div>
和css
#wrap { background:gray; width:400px; margin:0 auto; height:300px; border:5px blue solid; }
#info_box { width:300px; height:200px; background:pink; float:left; display:inline-block; overflow:hidden; display:none; }
#click_here { width:100px; height:200px; float:left; background:yellow; display:inline-block; }
http://jsfiddle.net/NinoLopezWeb/92Xcm/1/
谢谢!
【问题讨论】:
-
你能切换div吗?这样它会从点击这里jsfiddle.net/enXVM下方滑动
-
刚刚看到这个非常相似的问题和有趣的答案:stackoverflow.com/questions/10092794/…
标签: jquery