javascript - 自动调整所有屏幕的弹出框

标签 javascript jquery html css

我正在为博主使用电子邮件订阅弹出窗口,但这并没有明智地调整屏幕宽度。我该如何修改,以便自动为所有屏幕设置此电子邮件订阅弹出框?

代码如下:

jQuery(document).ready(function($) {
  if ($.cookie('popup-email-box') != 'yes') {
    $('.outer-email-popup-box').delay(10000).fadeIn('medium');
    $('.exit-button-subbox, .button').click(function() {
      $('.outer-email-popup-box').stop().fadeOut('medium');
    });
  }
  $.cookie('popup-email-box', 'yes', {
    path: '/',
    expires: 5
  });
});
.outer-email-popup-box {
  display: none;
  background: rgba(0, 0, 0, 0.8);
  width: 100%;
  height: 100%;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 99999;
}

.email-popup-box {
  width: 500px;
  height: 280px;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 25%;
  margin: auto;
  text-align: center;
  background: #fff;
  -webkit-animation: swinging 10s ease-in-out 0s infinite;
  -moz-animation: swinging 10s ease-in-out 0s infinite;
  animation: swinging 10s ease-in-out 0s infinite;
}

.email-popup-header {
  text-align: center;
  font-size: 2em;
  color: #FFFFFF;
  background: #006D90;
  padding: 4px 15px 7px 10px;
  margin: 13px 0px 14px 0px;
}

.email-popup-subheader {
  text-align: center;
  font-size: 1.1em;
  color: #676767;
  padding: 0px 0px 2px
}

.email-popup-body {
  text-align: center;
  margin-top: 9px;
  padding: 22px 0px 3px 0px;
  background: #006D90;
}

.email-right {
  background: green;
  float: right;
}

.email-left {
  background: red;
  float: left;
}

.email-form {
  width: 80%;
  margin: 0 auto;
}

.in-popup-mail {
  padding: 10px;
  margin: 0 auto;
  width: 270px
}

.btn-popup-mail {
  padding: 10px;
  background: #006D90;
  border: 2px solid #fff;
  color: #fff;
  margin: 0 auto;
}

.btn-popup-mail:hover {
  background: #003E52
}

.background-img {
  width: 40px;
  margin: 0 auto;
  padding-top: 5px
}

.exit-button-subbox {
  float: right;
  cursor: pointer;
  position: absolute;
  right: 0px;
  top: 0px;
  margin-top: 4px;
  margin-right: 4px;
}

.exit-button-subbox:before {
  content: "X";
  padding: 4px 4px;
  background: #FFFFFF;
  color: #000000;
  font-weight: normal;
  font-size: 15px;
  font-family: sans-serif;
}

.footer-popup-mail {
  color: #fff;
  font-size: 12px;
  margin-top: -5px
}

.footer-popup-mail a {
  color: #fff
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script type="text/javascript" src='http://aireshalili.github.io/internetsmash/popup-email-subscription.js'></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>

<div class="outer-email-popup-box">
  <div class="email-popup-box internetsmash-swing">
    <div class='exit-button-subbox'></div>
    <div class="background-img">
      <img src="http://1.bp.blogspot.com/-1oi5Hycb6mI/VoNMarSCB1I/AAAAAAAABLQ/9eC4C0x7wxo/s89-Ic42/mail.png" style="width:50px" />
    </div>
    <div class="email-popup-header">
      SUBCRIBE TO OUR NEWSLETTER
    </div>
    <div class="email-popup-header">
      <center>Join Today</center>
    </div>
    <div class="email-popup-subheader">
      Enter Email - Verify Email - Get Updates
    </div>
    <div class="email-popup-body">
      <div class="email-form">
        <form action="http://feedburner.google.com/fb/a/mailverify" method="post" onsubmit="window.open('http://feedburner.google.com/fb/a/mailverify?uri=FEEDBURNER-ID', 'popupwindow', 'scrollbars=yes,width=540,height=520'); return true" target="popupwindow">
          <table width="100%">
            <tbody>
              <tr>
                <td>
                  <input class="emailu in-popup-mail" name="email" placeholder="Enter your email address" type="text" />
                </td>
                <td>
                  <input class="mail-buttons btn-popup-mail" type="submit" value="SUBMIT" />
                </td>
              </tr>
            </tbody>
          </table>
          <input name="uri" type="hidden" value="FEEDBURNER-ID" />
          <input name="loc" type="hidden" value="en_US" />
        </form>
      </div>

    </div>
  </div>
</div>

最佳答案

/*Please replce your this code*/ 
   .email-popup-box {
        width: 95%;
        max-width: 500px; /* Auto resize popup box for all screen use max-width*/
        height: 280px;
        position: fixed;
        top: 9%;
        left: 0;
        right: 0;
        bottom: 25%;
        margin: 0 auto;
        text-align: center;
        background: #fff;
        -webkit-animation: swinging 10s ease-in-out 0s infinite;
        -moz-animation: swinging 10s ease-in-out 0s infinite;
        animation: swinging 10s ease-in-out 0s infinite;
        max-width: 500px;
        padding: 0 0;
    }

关于javascript - 自动调整所有屏幕的弹出框,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48127036/

相关文章:

javascript - Google Web Speech API 中的语法

javascript - 在 URL 中传递 base64 信息作为查询字符串的正确方法?

javascript - 使用 JavaScript/jQuery 将字符串分解为字符并将声音附加到每个字符

javascript - 调整窗口大小时刷新 Skrollr

html - 即使使用 Web 字体加载器,如何避免 Flash of Unstyled Text (FOUT)?

javascript - 下拉选择单付还是双付

javascript - 处理 Promise 拒绝案例 Mocha

javascript - 未捕获错误 : Syntax error, 无法识别的表达式:输入[name=ms_harga[]]

html - 使用 CSS 将文本分成行

来自实例的 Javascript 原型(prototype)