我想在此示例中使用一个简单的模式窗口http://jqueryui.com/dialog/,以便在页面主体在特定位置向下滚动时向上浮动。它可以是右上角,右下角或中间右侧。使用jQuery浮动模态窗口
我用他的代码:
$(function() { $("#dialog").dialog({ maxHeight: 200, width: 400, autoOpen: true, show: { effect: "blind", duration: 1000 }, hide: { effect: "explode", duration: 1000 } }); $("#opener").click(function() { $("#dialog").dialog("open"); }); $(window).scroll(function() { //after window scroll fire it will add define pixel added to that element. set = $(document).scrollTop() + "px"; //this is the jQuery animate function to fixed the div position after scrolling. $('#dialog').animate({ top: set }, { duration: 1000, queue: false }); }); });
怎么过,这只会浮在对话而不是整个窗口内的文本。
任何帮助将非常理解:)
请让一个jsfiddle并把代码。 – 2014-10-03 16:41:51
我试过,但没有工作... html代码是一样的http://jqueryui.com/dialog/ – Aslan 2014-10-03 16:42:42
你的位置:绝对'css? – Ohgodwhy 2014-10-03 16:46:30