【发布时间】:2020-03-17 19:41:02
【问题描述】:
我是编码新手,我正在尝试创建一个简单的弹出窗口,我希望能够使其与移动网站兼容,但我尝试从 W3 Schools 做一堆示例以使其对移动设备友好。我的尝试没有运气,所以我没有在我在这里发布的代码中包含我尝试过的任何内容。有人可以帮助我吗?谢谢!
$(function() {
var overlay = $('<div id="overlay"></div>');
overlay.show();
overlay.appendTo(document.body);
$('.popup').show();
$('.close').click(function() {
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
$('.x').click(function() {
$('.popup').hide();
overlay.appendTo(document.body).remove();
return false;
});
});
#overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000;
filter: alpha(opacity=70);
-moz-opacity: 0.7;
-khtml-opacity: 0.7;
opacity: 0.7;
z-index: 100;
display: none;
}
.cnt223 a {
text-decoration: none;
}
.popup {
width: 100%;
margin: 0 auto;
display: none;
position: fixed;
z-index: 101;
}
.cnt223 {
min-width: 600px;
width: 600px;
min-height: 150px;
margin: 100px auto;
background: #f3f3f3;
position: relative;
z-index: 103;
padding: 15px 35px;
border-radius: 5px;
box-shadow: 0 2px 5px #000;
}
.cnt223 p {
clear: both;
color: #555555;
/* text-align: justify; */
font-size: 20px;
font-family: sans-serif;
}
.cnt223 p a {
color: #d91900;
font-weight: bold;
}
.cnt223 .x {
float: right;
height: 35px;
left: 22px;
position: relative;
top: -25px;
width: 34px;
}
.cnt223 .x:hover {
cursor: pointer;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class='popup'>
<div class='cnt223'>
<Center>
<h1>POPUP!</h1>
<p>
<center>
Body text Lores Ipsum........
<br>
<br>
<b> The next line down</b>
<br/>
<br/>
<a href='' class='close'>Close</a>
</p>
</div>
</div>
【问题讨论】:
-
这在使用移动视图的 Chrome 开发工具中看起来不错。它响应旋转并根据屏幕大小进行调整。你有什么问题?
标签: javascript html css mobile mobile-safari