为什么我的 "Popup window" 没有在第二次点击时显示?
Why does my "Popup window" not showing for the second time on click?
我上面的代码在这里工作正常(如果我 运行 代码)但它导致我在我的网站上出错。
发生的事情是,第一次点击所有链接都正常,但是当我第二次尝试点击时,它显示空白页面,你不能点击页面上的任何地方,所以我必须刷新或点击后退按钮。
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
overflow:hidden;
z-index:9999999;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #000;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
@media screen and (max-width: 700px){
.popup{
width: 70%;
}
}
<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#1" >View</a></div>
<div id="1" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >×</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>
<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#2" >View</a></div>
<div id="2" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >×</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>
<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#3" >View 3</a></div>
<div id="3" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >×</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>
它在 Stack overflow 代码片段中工作得很好。
我想你的本地环境可能有问题。
尽管如果您需要任何帮助,请随时问我!
谢谢!
快乐编码!
根据您的指示,我了解到您网站中的 theme.js 文件存在问题。
每当您单击关闭 "x" 按钮时,该文件中 行号 105 的弹出函数都会触发并在弹出窗口中添加内联 css 并将弹出窗口的不透明度 div 降低为 "opacity:0".
解决方案:您可以只更改 class 名称并删除点击,即使作为临时解决方案也是如此。或者您可以编辑 theme.js 文件并减少代码并获得更好的性能...
选择权在你
我希望这会帮助你。否则你可以告诉我任何帮助!
谢谢!
编码愉快!!!
我上面的代码在这里工作正常(如果我 运行 代码)但它导致我在我的网站上出错。 发生的事情是,第一次点击所有链接都正常,但是当我第二次尝试点击时,它显示空白页面,你不能点击页面上的任何地方,所以我必须刷新或点击后退按钮。
.overlay {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
background: rgba(0, 0, 0, 0.7);
transition: opacity 500ms;
visibility: hidden;
opacity: 0;
overflow:hidden;
z-index:9999999;
}
.overlay:target {
visibility: visible;
opacity: 1;
}
.popup {
margin: 70px auto;
padding: 20px;
background: #fff;
border-radius: 5px;
width: 30%;
position: relative;
transition: all 5s ease-in-out;
}
.popup h2 {
margin-top: 0;
color: #333;
font-family: Tahoma, Arial, sans-serif;
}
.popup .close {
position: absolute;
top: 20px;
right: 30px;
transition: all 200ms;
font-size: 30px;
font-weight: bold;
text-decoration: none;
color: #000;
}
.popup .close:hover {
color: #06D85F;
}
.popup .content {
max-height: 30%;
overflow: auto;
}
@media screen and (max-width: 700px){
.popup{
width: 70%;
}
}
<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#1" >View</a></div>
<div id="1" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >×</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>
<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#2" >View</a></div>
<div id="2" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >×</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>
<div style="clear:both; height:23px; font-size:9px; color:#0033FF; text-align:right; margin-right:11px;"><a href="#3" >View 3</a></div>
<div id="3" class="overlay">
<div class="popup">
<h2>pop up window one </h2>
<a class="close" href="#" >×</a>
<div class="content">
this is my pop up window 1
</div>
</div>
</div>
它在 Stack overflow 代码片段中工作得很好。 我想你的本地环境可能有问题。
尽管如果您需要任何帮助,请随时问我!
谢谢! 快乐编码!
根据您的指示,我了解到您网站中的 theme.js 文件存在问题。
每当您单击关闭 "x" 按钮时,该文件中 行号 105 的弹出函数都会触发并在弹出窗口中添加内联 css 并将弹出窗口的不透明度 div 降低为 "opacity:0".
解决方案:您可以只更改 class 名称并删除点击,即使作为临时解决方案也是如此。或者您可以编辑 theme.js 文件并减少代码并获得更好的性能...
选择权在你 我希望这会帮助你。否则你可以告诉我任何帮助! 谢谢!
编码愉快!!!