添加导航栏后,我的模式上的关闭按钮在滚动时被隐藏
After adding a navigation bar the close button on my modal is hidden when scrolling
我创建了一个 JSfidle 来演示这个问题。基本上,关闭按钮应该位于模式 window 右上角的外侧,但是由于调整大小并向模式添加垂直滚动条,关闭按钮现在位于内部并在滚动时移动。有什么想法吗?
/* custom modal */
.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:1;
pointer-events: auto;
}
.modalDialog > div {
width: 750px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #f3eedd;
max-height: calc(100vh - 210px);
overflow-y:auto;
overflow-x:hidden;
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; }
hm1 {
font-family: 'Londrina Sketch', cursive;
color: #c13e18;
font-size: 50px;
text-align: center;
margin: 0px 30px 0px 30px;
}
hm2 {
font-size: 20px;
color: #c13e18;
margin: 10px 30px 10px 30px;
}
hm3 {
font-size: 20px;
margin: 30px 30px 0px 30px;
}
pm {
font-size: 20px;
margin: 0px 30px 0px 30px;
}
您应该将您的文本内容移动到它自己的 div(例如 class="content"),并将滚动应用到此内容:
.modalDialog > div {
width: 750px;
position: relative;
margin: 10% auto;
padding: 5px 0px 13px 20px;
border-radius: 10px;
background: #f3eedd;
overflow: visible;
}
.content{
max-height: calc(100vh - 210px);
overflow-y: auto;
padding-right: 20px;
}
我创建了一个 JSfidle 来演示这个问题。基本上,关闭按钮应该位于模式 window 右上角的外侧,但是由于调整大小并向模式添加垂直滚动条,关闭按钮现在位于内部并在滚动时移动。有什么想法吗?
/* custom modal */
.modalDialog {
position: fixed;
font-family: Arial, Helvetica, sans-serif;
top: 0;
right: 0;
bottom: 0;
left: 0;
background: rgba(0,0,0,0.8);
z-index: 99999;
opacity:0;
-webkit-transition: opacity 400ms ease-in;
-moz-transition: opacity 400ms ease-in;
transition: opacity 400ms ease-in;
pointer-events: none;
}
.modalDialog:target {
opacity:1;
pointer-events: auto;
}
.modalDialog > div {
width: 750px;
position: relative;
margin: 10% auto;
padding: 5px 20px 13px 20px;
border-radius: 10px;
background: #f3eedd;
max-height: calc(100vh - 210px);
overflow-y:auto;
overflow-x:hidden;
}
.close {
background: #606061;
color: #FFFFFF;
line-height: 25px;
position: absolute;
right: -12px;
text-align: center;
top: -10px;
width: 24px;
text-decoration: none;
font-weight: bold;
-webkit-border-radius: 12px;
-moz-border-radius: 12px;
border-radius: 12px;
-moz-box-shadow: 1px 1px 3px #000;
-webkit-box-shadow: 1px 1px 3px #000;
box-shadow: 1px 1px 3px #000;
}
.close:hover { background: #00d9ff; }
hm1 {
font-family: 'Londrina Sketch', cursive;
color: #c13e18;
font-size: 50px;
text-align: center;
margin: 0px 30px 0px 30px;
}
hm2 {
font-size: 20px;
color: #c13e18;
margin: 10px 30px 10px 30px;
}
hm3 {
font-size: 20px;
margin: 30px 30px 0px 30px;
}
pm {
font-size: 20px;
margin: 0px 30px 0px 30px;
}
您应该将您的文本内容移动到它自己的 div(例如 class="content"),并将滚动应用到此内容:
.modalDialog > div {
width: 750px;
position: relative;
margin: 10% auto;
padding: 5px 0px 13px 20px;
border-radius: 10px;
background: #f3eedd;
overflow: visible;
}
.content{
max-height: calc(100vh - 210px);
overflow-y: auto;
padding-right: 20px;
}