【问题标题】:Why does my "Popup window" not showing for the second time on click?为什么我的“弹出窗口”在点击时第二次没有显示?
【发布时间】:2020-07-29 17:52:25
【问题描述】:

我上面的代码在这里工作正常(如果我运行代码),但它导致我的网站上出现错误。 发生的事情是,第一次点击所有链接都可以正常工作,但是当我尝试第二次点击时,它会显示空白页面,您无法点击页面上的任何位置,所以我必须刷新或点击返回按钮。

.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="#" >&times;</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="#" >&times;</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="#" >&times;</a>
		<div class="content">
			this is my pop up window 1
		</div>
	</div>
</div>

【问题讨论】:

标签: html css popup window


【解决方案1】:

根据您的指示,我了解到您网站中的 theme.js 文件存在问题。

每当您单击弹出窗口的关闭 "x" 按钮时,该文件中 第 105 行 处的函数都会触发并在您的弹出窗口中添加内联 css 并减少弹出 div 的不透明度为 "opacity:0"

解决方案:您可以只更改该类名称并删除点击,即使作为临时解决方案也是如此。或者您可以编辑 theme.js 文件并减少代码并获得更好的性能...

选择权在你 我希望这会对你有所帮助。否则你可以告诉我任何帮助! 谢谢!

编码愉快!!!

【讨论】:

  • 你是天才。它解决了我的问题。我刚刚将班级名称从 close 更改为 close 并且效果很好。做得好。抱歉不能给你从 0 到 1 的评分,因为我没有太多的排名。但是我已经在标志上勾选了绿色,因为它已经解决了。
【解决方案2】:

它在堆栈溢出代码 sn-p 中完美运行。 我认为您的本地环境可能存在问题。

如果您需要任何帮助,请随时问我!

谢谢! 快乐编码!

【讨论】:

  • 它在我的页面上不起作用。只需在此页面上多次单击查看。 sublimefurnishings.co.uk/198/hmo_furniture_packages/…
  • 我在这个网站上究竟哪里不需要点击?
  • 您可以在右侧每 6 个框下方看到文本链接“视图”(如果您使用的是台式电脑)
  • 查看我的下一个答案以了解确切的问题
  • 已开启,希望对您有所帮助!
猜你喜欢
  • 1970-01-01
  • 2012-09-02
  • 1970-01-01
  • 1970-01-01
  • 2012-05-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-16
相关资源
最近更新 更多