我在我的网站上有一个页面,当用户基于某种条件进入它时,我想通过使用jQuery,从屏幕的顶部中心滑下一个对话框到页面的中心,但仍然允许用户上下滚动底层页面,但需要确认对话框以关闭页面或单击底层窗口的"X“(右上角),以关闭窗口。
请注意,当用户向上和向下滚动(即非模式)时,我希望始终保持对话框居中。
我使用的是Windows XP和MS IE8。
发布于 2011-03-20 22:32:34
试试jQuery UI's dialog。
编辑:不确定这是否是最好的方法,但我是这样做的:
$("<div />", { html:"Test." }).dialog({ autoOpen: true, position: "top" }).dialog( "widget" ).css({"position":"fixed","top":"0"}).animate({ top: "40%" }, 1000);发布于 2011-03-20 22:45:29
详细介绍另一个答案时,您需要将一些类添加到jQueryUI的对话框的dialogClass中,以便它始终以页面为中心。(例如position: fixed)
http://jsfiddle.net/BWqWT/
https://stackoverflow.com/questions/5369050
复制相似问题