jquery ui show() 方法在具有浮动子 div 的 div 上无法正常工作
我试图让一个 div 包含形成 2 个或更多列的子 div,然后我希望能够使用 jquery ui 盲效果使所有列同时出现,然后在延迟后淡出。然而,当我这样做时,列确实会出现,但不会出现盲目效果,它们只是一次全部出现,但淡出效果效果很好。如果我从子 div 中删除浮动样式,盲效果会起作用,但它们不会形成并排的列。所以我的问题是这应该是这样的吗?我应该在 Html 中为这项工作形成列的另一种方法吗?或者我没有正确使用jquery ui?任何帮助表示赞赏。
我的 html 的简化版本如下:
<style type="text/css">
.displayBox {width:440px; margin:0 auto; display:block;}
.column { width:200px; }
.left { float:left; }
.right { float:right; }
</style>
<script type ="text/javascript">
$(function () {
function callback() {
setTimeout(function () {
$("#box:visible").removeAttr("style").fadeOut();
}, 2000);
};
// set effect from select menu value
$("#clickme").click(function () {
$("#box").show("blind", { diection: "up" }, 1000, callback);
});
});
</script>
<div>
<input id="clickme" type="button" value="click" name="click" />
</div>
<div id="box" class="displayBox">
<div class="left column">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum<br /><br />Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
<div class="right column">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum<br /><br />Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
</div>
I trying to have a div with child divs that form 2 or more columns, I then want to be able to make all the columns appear at once using a jquery ui blind effect and then fade out after a delay. However when I do this the columns do appear but not with blind effect they just appear all at once, the fade out effect however works fine. If I remove the float style from the child divs the blind effect works but the they are not forming side by side columns. So my questions are is this supposed to be like this? Is another way I should be forming columns in Html for this work? Or am I not using jquery ui correctly? Any help appreciated.
A simplified version of my html is as follows:
<style type="text/css">
.displayBox {width:440px; margin:0 auto; display:block;}
.column { width:200px; }
.left { float:left; }
.right { float:right; }
</style>
<script type ="text/javascript">
$(function () {
function callback() {
setTimeout(function () {
$("#box:visible").removeAttr("style").fadeOut();
}, 2000);
};
// set effect from select menu value
$("#clickme").click(function () {
$("#box").show("blind", { diection: "up" }, 1000, callback);
});
});
</script>
<div>
<input id="clickme" type="button" value="click" name="click" />
</div>
<div id="box" class="displayBox">
<div class="left column">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum<br /><br />Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
<div class="right column">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum<br /><br />Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum
</div>
</div>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要在
#box
上设置height
才能使插件正常工作。这是您可以使用的 jsfiddle:查看源代码插件的:
我不知道这是否对您有帮助,因为您可能想让它流动,但是设置足够大的高度可能会使其按照您的需要工作。
另请注意,
direction
可以是vertical
或horizontal
,请参阅插件文档:,
vertical
是默认值,并且您有一个上面的拼写错误(diection
而不是direction
)。You need to set
height
on#box
for the plugin to work. Here's the jsfiddle you can play with:Take a look at the source of the plugin:
I don't know if this helps you, as you probably want to let it flow, but setting some height that is big enough might make it work as you need.
Also, note that
direction
is eithervertical
orhorizontal
, see the plugin docs:that
vertical
is a default and that you had a typo above (diection
instead ofdirection
).