Javascript 为移动设备调整页面大小时,引导模式会向下移动页面
我有一个模式,点击我的页面弹出。它在浏览器视图和较小视图中完全居中。在我将页面缩小到手机的那一刻,模态会沿着页面向下移动,我必须滚动才能看到它。我怎样才能解决这个问题Javascript 为移动设备调整页面大小时,引导模式会向下移动页面,javascript,html,css,twitter-bootstrap,Javascript,Html,Css,Twitter Bootstrap,我有一个模式,点击我的页面弹出。它在浏览器视图和较小视图中完全居中。在我将页面缩小到手机的那一刻,模态会沿着页面向下移动,我必须滚动才能看到它。我怎样才能解决这个问题 .nx-modal { position: absolute; padding: 20px; background-color: #fff; border-radius: 15px; z-index: 1050; width: 96%; } 是否有任何其他样式指定给替代的模态?例如,像媒体查询?您可以尝试为较小的屏幕添加媒体查
.nx-modal {
position: absolute;
padding: 20px;
background-color: #fff;
border-radius: 15px;
z-index: 1050;
width: 96%;
}
是否有任何其他样式指定给替代的模态?例如,像媒体查询?您可以尝试为较小的屏幕添加媒体查询,并为您的模式atop:0px
和left:0px
在这种情况下可能会有所帮助
试试这个
@media only screen and (max-width : 768px) {
.modal {
position: fixed;
top: 0;
margin:0;
padding:10px;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
width: 96%;
}
}
@media only screen and (max-width : 768px) {
.modal {
position: fixed;
top: 0;
margin:0;
padding:10px;
right: 0;
bottom: 0;
left: 0;
z-index: 1050;
width: 96%;
}
}