关闭一次并重新打开后,css模态不能被解雇

时间:2015-08-25 05:11:27

标签: html css modal-dialog

这是我用于自动弹出式css模式的代码。问题是当自动弹出窗口在同一页面上第二次出现时,我无法通过单击关闭按钮关闭它。有没有办法通过点击背景关闭它?如果是,我应该添加什么代码?感谢。

JSFiddle

<div class="popup-wrapper" id="popup">
  <div class="popup-container">
    <!-- Konten popup, silahkan ganti sesuai kebutuhan -->
    <form action="http://www.syakirurohman.net/2015/01/tutorial-membuat-popup-tanpa-javascript-jquery.html#" method="post" class="popup-form">
      <h2>Ikuti Update !!</h2>
      <p>Daripada hanya melihat demo untuk popup-nya saja, lebih baik masukkan juga email anda agar mendapatkan pemberitahuan saat ada update posting menarik lain seperti ini.<br/>
        <strong>Percayalah, saya hanya akan mengirim sesuatu yang bermanfaat untuk anda :)</strong>
      </p>
      <div class="input-group">
        <p><input type="email" name="email" placeholder="Email Address"></p>
        <p>
          <input type="hidden" name="action" value="subscribe">
          <input type="hidden" name="source" value="http://www.syakirurohman.net/2015/01/tutorial-membuat-popup-tanpa-javascript-jquery.html">
          <input type="hidden" name="sub-type" value="widget">
          <input type="hidden" name="redirect_fragment" value="blog_subscription-2">
          <input type="hidden" id="_wpnonce" name="_wpnonce" value="aaf0b68fcd">
          <input type="submit" value="Submit" name="jetpack_subscriptions_widget">
        </p>
      </div>
    </form>
    <!-- Konten popup sampai disini--><a class="popup-close" href="#popup">X</a>
  </div>
</div>

css

/* style untuk link popup */

a.popup-link {
    padding: 17px 0;
    text-align: center;
    margin: 10% auto;
    position: relative;
    width: 300px;
    color: #fff;
    text-decoration: none;
    background-color: #FFBA00;
    border-radius: 3px;
    box-shadow: 0 5px 0px 0px #eea900;
    display: block;
}
a.popup-link:hover {
    background-color: #ff9900;
    box-shadow: 0 3px 0px 0px #eea900;
    -webkit-transition: all 1s;
    transition: all 1s;
}
/* end link popup*/
/* animasi popup */

@-webkit-keyframes autopopup {
    from {
        opacity: 0;
        margin-top: -200px;
    }
    to {
        opacity: 1;
    }
}
@-moz-keyframes autopopup {
    from {
        opacity: 0;
        margin-top: -200px;
    }
    to {
        opacity: 1;
    }
}
@keyframes autopopup {
    from {
        opacity: 0;
        margin-top: -200px;
    }
    to {
        opacity: 1;
    }
}
/* end animasi popup */
/*style untuk popup */

#popup {
    background-color: rgba(0, 0, 0, 0.7);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    -webkit-animation: autopopup 2s;
    -moz-animation: autopopup 2s;
    animation: autopopup 2s;
}
#popup:target {
    -webkit-transition: all 1s;
    -moz-transition: all 1s;
    transition: all 1s;
    opacity: 0;
    visibility: hidden;
}
@media (min-width: 768px) {
    .popup-container {
        width: 600px;
    }
}
@media (max-width: 767px) {
    .popup-container {
        width: 100%;
    }
}
.popup-container {
    position: relative;
    margin: 7% auto;
    padding: 30px 50px;
    background-color: #fafafa;
    color: #333;
    border-radius: 3px;
}
a.popup-close {
    position: absolute;
    top: 3px;
    right: 3px;
    background-color: #333;
    padding: 7px 10px;
    font-size: 20px;
    text-decoration: none;
    line-height: 1;
    color: #fff;
}
/* end style popup */
/* style untuk isi popup */

.popup-form {
    margin: 10px auto;
}
.popup-form h2 {
    margin-bottom: 5px;
    font-size: 37px;
    text-transform: uppercase;
}
.popup-form .input-group {
    margin: 10px auto;
}
.popup-form .input-group input {
    padding: 17px;
    text-align: center;
    margin-bottom: 10px;
    border-radius: 3px;
    font-size: 16px;
    display: block;
    width: 100%;
}
.popup-form .input-group input:focus {
    outline-color: #FB8833;
}
.popup-form .input-group input[type="email"] {
    border: 0px;
    position: relative;
}
.popup-form .input-group input[type="submit"] {
    background-color: #FB8833;
    color: #fff;
    border: 0;
    cursor: pointer;
}
.popup-form .input-group input[type="submit"]:focus {
    box-shadow: inset 0 3px 7px 3px #ea7722;
}
/* end style isi popup */

0 个答案:

没有答案