无法关闭弹出窗口

时间:2020-04-23 15:12:05

标签: css modal-dialog popup

我需要在我的网站(wordpress)上使用没有javascript的模式弹出窗口(仅CSS)。但是close不能像在测试或在线html编辑器中那样工作。

从此链接转到代码: https://www.webdesignerdepot.com/cdn-origin/uploads7/creating-a-modal-window-with-html5-and-css3/demo.html

让它可以在页面上加载,但关闭按钮并未隐藏我网站上的弹出窗口。我要为主页添加以下代码和文本小部件。

<style>
.modalDialog {
 position: fixed;
 font-family: Arial, Helvetica, sans-serif;
 top: 0;
 right: 0;
 bottom: 0;
 left: 0;
 background: rgba(0, 0, 0, 0.2);
 z-index: 99999;
 opacity: 1;
 -webkit-transition: opacity 400ms ease-in;
 -moz-transition: opacity 400ms ease-in;
 transition: opacity 400ms ease-in;
 pointer-events: auto;
}

.modalDialog:target {
 opacity: 0;
 pointer-events: auto;
}

.modalDialog > div {
 width: 40%;
 height: auto;
 min-width: 650px;
 position: relative;
 margin: 1% auto;
 padding: 5px 20px 13px 20px;
 border-radius: 10px;
 background: #fff;
 background: -moz-linear-gradient(#fff, #999);
 background: -webkit-linear-gradient(#fff, #999);
 background: -o-linear-gradient(#fff, #999);
}

.close {
 background: #cd9934;
 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: grey;
}

</style>

<div id="openModal" class="modalDialog">
 <div> <a href="#openModal" title="Close" class="close">x</a>

 <p style="text-align: center;"><img class="aligncenter size-full" src="https://www.w3schools.com/css/img_chania.jpg" alt=""  /></p>

</div>
</div>

0 个答案:

没有答案