ManuParra
ManuParra

Reputation: 1531

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

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.

Upvotes: 2

Views: 19832

Answers (2)

user1993579
user1993579

Reputation: 11

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'});

Upvotes: 1

frenchie
frenchie

Reputation: 51997

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'});

Upvotes: 3

Related Questions