I want to pop up a div just on the position where I click the page. So I have the following HTML.
<HTML>
<body>
<button id="popupButton"> click </button>
<div id="popupFilterDiv" class="popupFilterDiv" style="display:none;">
<input type="checkbox" name="statusFilter" value="Active" /> Active <br />
<input type="checkbox" name="statusFilter" value="Expired" /> Expired <br />
</div>
</body>
</HTML>
the js is:
$("#popupButton").live('click', function (e) {
leftVal = e.pageX + "px";
topVal = e.pageY + "px";
$('#popupFilterDiv').css({ left: leftVal, top: topVal }).show();
});
and css is:
.popupFilterDiv
{
background-color:#FFFFFF;
border:1px solid #999999;
cursor:default;
display:none;
margin-top: 10px;
position: absolute;
text-align:left;
z-index:50;
padding: 15px 15px 5px;
top: 0px;
left: 0px;
}
Now, everything works well except that, when I change the width of the web browser, the pop up div lies far away from the popupButton, and the shape of the pop up div also changed.
What I expected is
while when I change the width of the web browser, it becomes disordered.
It may not be very elegant, but you could give your .popupFilterDiv
class a fixed width:
.popupFilterDiv
{
/*other relevant styles*/
position: absolute;
width: 50px; /* set a fixed width */
top: 0px;
left: 0px;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.