How to position popup at top of screen or fixed at top in jquery mobile?

为君一笑 提交于 2019-12-11 03:23:55

问题


I have a popup in jquery mobile

<div data-role="popup"   id="itemDetails">
...
</div>

and I call programmatically to open with:

$('#itemDetails').popup('open');

, but always open centered in x,y on screen, and I want show fix to top (y=0) of screen, and fixed when I have scroll.

How I can do it?, Thanks in advance.


回答1:


Something like CSS should be enough:

#itemDetails{
  position:fixed;
  top:0px;
}

If you really want to use jQuery, then

$('#itemDetails').css({position:'fixed',top:'0'});



回答2:


The solution did not work for me. Putting the css in the .css file did not take effect. I found that I needed to use the second type with:

$("#popupBasic").popup('open');
$('#popupBasic').css({position:'fixed',top:'10px',left:'30px','display':'block'});

then to close the popup:

$('#popupBasic').popup('close');
$('#popupBasic').css({display:'none'});


来源:https://stackoverflow.com/questions/15130420/how-to-position-popup-at-top-of-screen-or-fixed-at-top-in-jquery-mobile

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!