gpt4 book ai didi

jquery - 使弹出式 div 在移动设备上响应

转载 作者:行者123 更新时间:2023-11-28 03:22:23 25 4
gpt4 key购买 nike

我正在尝试让我的弹出式 div 在移动设备上响应。它在网站上工作得很好,但在我的移动设备上你无法退出弹出窗口,而且它太大了。我假设我必须使用媒体查询,但我已经尝试了一些,但我对媒体查询不太熟悉。我提供了问题的屏幕截图和弹出窗口的代码。

CSS:

    <style>
#close{
width: 20px;
height: 20px;
background: #000;
border-radius: 50%;
border: 3px solid #fff;
display: block;
text-align: center;
color: #fff;
text-decoration: none;
position: absolute;
top: -15px;
right: -15px;
cursor: pointer;
}

</style>

<!--Shop Now Button-->
<style>

#btn1{
position:absolute;
float: center;
width: 300px;
height: 50px;
font-size: 20px;
font-weight: bold;
/* box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); */
margin-top:320px; /*brings buttons down*/
margin-left:60px;
}


#emailf{
position:absolute;
float: center;
width: 300px;
height: 40px;
font-size: 20px;
color:black;
font-weight: bold;
/* box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); */
margin-top:200px; /*brings buttons down*/
margin-left:60px;
}

#password1 {
position:absolute;
float: center;
width: 300px;
height: 40px;
font-size: 20px;
color:black;
font-weight: bold;
/* box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19); */
margin-top:260px; /*brings buttons down*/
margin-left:60px;
}


</style>

<!-- CSS for the Popup Box -->
<style>




#hider
{
position:fixed;
top: 0%;
left: 0%;
width:9000px;
height:9000px;
margin-top: -100px; /*set to a negative number 1/2 of your height*/
margin-left: -200px; /*set to a negative number 1/2 of your width*/
opacity:0.8;
background-color:#666;
z-index:99999;

}

#popup_box
{
background-image: url('https://cdn.shopify.com/s/files/1/0569/4201/files/popupbanner_3.jpg?11297628032998908977');
position:fixed;
top: 50%;
left: 50%;
width:450px;
height:570px;
margin-top: -315px; /*set to a negative number 1/2 of your height*/
margin-left: -225px; /*set to a negative number 1/2 of your width*/

z-index:999999;

border: none;
border: none;
padding: 40px;


}


</style>

JavaScript/JQUERY:

  <script>

$(document).ready(function () {
//hide hider and popup_box
$("#hider").hide
$('#popup_box').fadeIn("slow");

//on click show the hider div and the message
$("#showpopup").click(function () {
$("#hider").fadeIn("slow");

});


//on click hide the message
$("#close").click(function () {

$("#hider").fadeOut("slow");
$('#popup_box').fadeOut("slow");
$('#popup_box').close;

});

$("#shop").click(function () {

$("#hider").fadeOut("slow");
$('#popup_box').fadeOut("slow");
});

$(document).keyup(function(e) {
if (e.keyCode == 27) {
$("#hider").fadeOut("slow");
$('#popup_box').fadeOut("slow");
$('#popup_box').close;
}
});

});


function PopUp(hideOrshow) {
if (hideOrshow == 'hide') {
document.getElementById('ac-wrapper').style.display = "none";
}
else if(localStorage.getItem("popupWasShown") == null) {
localStorage.setItem("popupWasShown",1);
document.getElementById('ac-wrapper').removeAttribute('style');
}
}
window.onload = function () {
setTimeout(function () {
PopUp('show');
}, 0);
}


function hideNow(e) {
if (e.target.id == 'ac-wrapper') document.getElementById('ac-wrapper').style.display = 'none';
}

</script>

HTML:

<div id="ac-wrapper" style='display:none' onClick="hideNow(event)"> 
<div id="hider"></div>
<div id="popup_box" >




<br>
{% form 'create_customer' %}


<center>
<div id="emailf" class="clearfix large_form">
<label for="email" class="label"></label>
<input type="email" value="" name="customer[email]"placeholder="Email" id="email" class="text" style="text-align:center; margin: 0 auto; width:300px; height:30px;" />
</div>
<div id="password1" class="clearfix large_form">
<label for="password" class="label"></label>
<input type="password" value="" name="customer[password]"placeholder="Password" id="password" class="password text" style="text-align:center; margin: 0 auto; width:300px; height:30px;" />
</div>



<div id="btn1" class="clearfix large_form">
<label for="Create" class="btn1"></label>
<input type="submit" value="SIGN UP!" style="text-align:center; font-weight:bold;margin: 0 auto; width:310px; height:40px;background-color:#852B8A;color:white;" />
</div>
<div id="close">X</div>
<!-- <input class="btn1" type="submit" value="Create" />-->
<!-- <button id="shop"><a href="https://www.alzerina.com/collections/ready-to-wear">Sign Up Now!</a></button> -->

</center>
</div> {% endform %}
</div>

您可以在 alzerina.com 查看网页版的弹出窗口

This is the current problem on the mobile version

最佳答案

你可以像这样使用媒体查询:

<style>
@media (max-width: 600px) {
#popup_box{
top: 0;
left: 0;
width:100%;
max-width: 100%;
height:100%;
}
}
</style>

关于jquery - 使弹出式 div 在移动设备上响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45148115/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com