第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

無法使用 javascript 使窗口淡入淡出或在 css 中添加過渡效果

無法使用 javascript 使窗口淡入淡出或在 css 中添加過渡效果

30秒到達戰(zhàn)場 2023-10-24 16:01:11
我一直在使用該fadeOut功能時遇到問題,以便在關(guān)閉窗口彈出消息時添加效果。同時,我嘗試過在CSS中給div添加過渡效果,但也沒有成功。我的想法是在 JavaScript 部分的語句中添加這種淡入淡出效果if,但這不起作用。<body>  <div class="container">    <div class="window" id="win">      <div class="layover">        <div class="h2">          <h2>Oops!</h2>        </div>        <div class="yesandno">          <figure class="yes">            <button onclick="window.location.href= 'espanol.html';">Si</button>          </figure>          <figure class="no">            <button onclick id="buttonn">No</button>          </figure>        </div>        <div class="langmessage">          Hemos detectado que el idioma de su ordenador se encuentra en espa?ol. ?Le gustaría utilizar la versión en espa?ol de nuestro sitio web?        </div>      </div>    </div>  </div>  <script type="text/javascript">    var lang = navigator.language;    if ("" + lang == "es-US") {      var div = document.getElementById("win");    }    var button = document.getElementById("buttonn")    buttonn.onclick = function() {      var div = document.getElementById("win");      if (div.style.display !== "none") {        div.style.display = "none";      }    }  </script></body>
查看完整描述

1 回答

?
qq_遁去的一_1

TA貢獻1725條經(jīng)驗 獲得超8個贊

為了使用該fadeOut()方法,您必須將其包含jQuery到您的項目中,但您也可以使用純 JavaScript 手動對其進行編程。下面是兩種解決方案,一種使用普通的jQuery,另一種使用普通的javascript。

jQuery 解決方案:

注意:如果使用jQuery,您可以重寫部分代碼,例如document.getElementById("win")$("#win"),但這超出了問題的范圍。

var lang = navigator.language;

if ("" + lang == "es-US") {

  var div = document.getElementById("win");

}


var buttonn = document.getElementById("buttonn");


buttonn.onclick = function() {

  var div = document.getElementById("win");

  if (div.style.display !== "none") {

    $("#win").fadeOut();

  }

}

.window {

  position: fixed;

  border-width: 0px;

  top: 0;

  right: 0;

  left: 0;

  bottom: 0;

  margin: auto;

  padding: 0px;

  background: url(images/blue-abstract-noise-free-website-background-image.jpg);

  border-radius: 12px;

  width: 476px;

  height: 276px;

  opacity: 1;

  z-index: 1;

  box-shadow: 2px 1px 2.82px 1.8px rgba(209, 55, 55, 0.486), 0px 3px 5.88px 0.12px rgba(211, 49, 49, 0.514);

}


.layover {

  background-color: rgba(100, 99, 92, 0.699);

  position: absolute;

  right: 0px;

  top: 0px;

  width: 100%;

  height: 100%;

  border-radius: 12px;

}


.h2 {

  position: absolute;

  left: 12px;

  font-weight: 900;

  font-size: 20px;

  color: white;

  font-family: sans-serif;

}


.yesandno {

  height: 80px;

  width: 250px;

  position: absolute;

  top: 200px;

  left: 217px;

}


.yes {

  display: inline-block;

  position: absolute;

  height: 30px;

  width: 80px;

  margin: 0px;

  left: 100px;

}


.yes>button {

  display: block;

  cursor: pointer;

  margin: 0px;

  padding: 0px;

  border: 0px;

  border-radius: 8px;

  height: 100%;

  width: 100%;

  color: white;

  font-weight: 900;

  font-size: 13px;

  font-family: sans-serif;

  opacity: 1;

  z-index: 2;

  background-color: rgba(129, 127, 127, 0.808);

}


.no {

  display: inline-block;

  position: absolute;

  height: 30px;

  width: 80px;

  margin: 0px;

  right: 300px;

}


.no>button {

  display: block;

  cursor: pointer;

  margin: 0px;

  padding: 0px;

  border: 0px;

  border-radius: 8px;

  height: 100%;

  width: 100%;

  color: white;

  font-weight: 900;

  font-size: 13px;

  font-family: sans-serif;

  opacity: 1;

  z-index: 2;

  background-color: rgba(129, 127, 127, 0.808);

}


.langmessage {

  position: absolute;

  top: 80px;

  text-align: center;

  font-weight: 900;

  font-size: 13px;

  font-family: sans-serif;

  color: white;

  left: 10px;

  right: 10px;

}

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


<div class="container">

  <div class="window" id="win">

    <div class="layover">

      <div class="h2">

        <h2>Oops!</h2>

      </div>

      <div class="yesandno">

        <figure class="yes">

          <button onclick="window.location.href= 'espanol.html';">Si</button>

        </figure>

        <figure class="no">

          <button onclick id="buttonn">No</button>

        </figure>

      </div>

      <div class="langmessage">

        Hemos detectado que el idioma de su ordenador se encuentra en espa?ol. ?Le gustaría utilizar la versión en espa?ol de nuestro sitio web?

      </div>

    </div>

  </div>

</div>

普通 JavaScript 解決方案:


var lang = navigator.language;

if ("" + lang == "es-US") {

  var div = document.getElementById("win");

}

var buttonn = document.getElementById("buttonn");


buttonn.onclick = function() {

  var div = document.getElementById("win");

  if (div.style.display !== "none") {

    fadeOutPopup();

  }

}

    

function fadeOutPopup() {

  var elem = document.getElementById("win");

  var fade = setInterval(function () {

      if (!elem.style.opacity) {

          elem.style.opacity = 1;

      }

      if (elem.style.opacity > 0) {

          elem.style.opacity -= 0.2;

      } else {

          clearInterval(fade);

      }

  }, 50);

}

.window {

  position: fixed;

  border-width: 0px;

  top: 0;

  right: 0;

  left: 0;

  bottom: 0;

  margin: auto;

  padding: 0px;

  background: url(images/blue-abstract-noise-free-website-background-image.jpg);

  border-radius: 12px;

  width: 476px;

  height: 276px;

  opacity: 1;

  z-index: 1;

  box-shadow: 2px 1px 2.82px 1.8px rgba(209, 55, 55, 0.486), 0px 3px 5.88px 0.12px rgba(211, 49, 49, 0.514);

}


.layover {

  background-color: rgba(100, 99, 92, 0.699);

  position: absolute;

  right: 0px;

  top: 0px;

  width: 100%;

  height: 100%;

  border-radius: 12px;

}


.h2 {

  position: absolute;

  left: 12px;

  font-weight: 900;

  font-size: 20px;

  color: white;

  font-family: sans-serif;

}


.yesandno {

  height: 80px;

  width: 250px;

  position: absolute;

  top: 200px;

  left: 217px;

}


.yes {

  display: inline-block;

  position: absolute;

  height: 30px;

  width: 80px;

  margin: 0px;

  left: 100px;

}


.yes>button {

  display: block;

  cursor: pointer;

  margin: 0px;

  padding: 0px;

  border: 0px;

  border-radius: 8px;

  height: 100%;

  width: 100%;

  color: white;

  font-weight: 900;

  font-size: 13px;

  font-family: sans-serif;

  opacity: 1;

  z-index: 2;

  background-color: rgba(129, 127, 127, 0.808);

}


.no {

  display: inline-block;

  position: absolute;

  height: 30px;

  width: 80px;

  margin: 0px;

  right: 300px;

}


.no>button {

  display: block;

  cursor: pointer;

  margin: 0px;

  padding: 0px;

  border: 0px;

  border-radius: 8px;

  height: 100%;

  width: 100%;

  color: white;

  font-weight: 900;

  font-size: 13px;

  font-family: sans-serif;

  opacity: 1;

  z-index: 2;

  background-color: rgba(129, 127, 127, 0.808);

}


.langmessage {

  position: absolute;

  top: 80px;

  text-align: center;

  font-weight: 900;

  font-size: 13px;

  font-family: sans-serif;

  color: white;

  left: 10px;

  right: 10px;

}

<div class="container">

  <div class="window" id="win">

    <div class="layover">

      <div class="h2">

        <h2>Oops!</h2>

      </div>

      <div class="yesandno">

        <figure class="yes">

          <button onclick="window.location.href= 'espanol.html';">Si</button>

        </figure>

        <figure class="no">

          <button onclick id="buttonn">No</button>

        </figure>

      </div>

      <div class="langmessage">

        Hemos detectado que el idioma de su ordenador se encuentra en espa?ol. ?Le gustaría utilizar la versión en espa?ol de nuestro sitio web?

      </div>

    </div>

  </div>

</div>


查看完整回答
反對 回復 2023-10-24
  • 1 回答
  • 0 關(guān)注
  • 125 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號