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

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

將類分配給上一個 div 在幻燈片放映按鈕上單擊

將類分配給上一個 div 在幻燈片放映按鈕上單擊

楊魅力 2022-08-04 17:52:35
我目前正在嘗試制作一個動畫幻燈片,所以當你點擊函數(shù)時,盒子來自左邊的Div,但是當你點擊函數(shù)時,它來自右邊的div。plusDiv(-1)plusDiv(+1)錯誤:Javascript只抓取第一個“mySlides”,而它應該抓取上一張幻燈片。因此,如果在幻燈片3上,使幻燈片2出現(xiàn)。任何幫助將不勝感激,我已經嘗試這樣做了幾個小時,但似乎沒有什么可以解決問題。CSS:<style>    .mySlides {position: absolute;animation: MoveLeft 1s;animation-fill-mode: forwards; }    .classname { animation-name: MoveRight;position: absolute;-animation-fill-mode: forwards;}@keyframes MoveLeft {  0%   {position: absolute; margin-top: 50px; margin-left: 62.5%; width: 150px; height: 200px;}  100% {position: absolute; margin-left: 40%; width: 300px; height: 400px;}  to  {position: absolute; margin-left: 40%; width: 20%; height: auto;}}@keyframes MoveRight {  0%   {position: absolute; margin-top: 50px; margin-left: 25%; width: 150px; height: 200px;}  100% {position: absolute; margin-left: 40%; width: 300px; height: 400px;}  to  {position: absolute; margin-left: 40%; width: 20%; height: auto;}}</style>`網(wǎng)頁:<div style="position: absolute; margin-top: 5%; margin-left: 5%; width: 90%; height: 300px;">            <div style="position: relative; width: 100%; height: 100%;">                <div style="position: absolute; margin-top: 50px; margin-left: 25%; width: 20%; height: auto;"><img  id="BackaImage" onclick="onClick(); plusDivs(-1);" src="https://dummyimage.com/150x200/FF0000/FF0000"></div>                <img class="mySlides" id="unique" src="https://dummyimage.com/300x400/000/fff">                <img class="mySlides" id="unique"  src="https://dummyimage.com/300x400/ff00ff/2d3bfc">                <img class="mySlides" id="unique"  src="https://dummyimage.com/300x400/FF0000/FF00">                <div style="position: absolute; margin-top: 50px; margin-left: 62.5%; width: 20%; height: auto;"><img onclick="plusDivs(+1);" src="https://dummyimage.com/150x200/FF0000/FF0000"></div>            </div>        </div>
查看完整描述

1 回答

?
莫回無

TA貢獻1865條經驗 獲得超7個贊

我想我設法得到了你想要的東西。你差不多在那里,你只需要讓它更簡單一點。


我沒有改變他們的類名,而是從Javascript改變了他們的動畫風格。如果您出于其他原因需要更改他們的類名,您也可以這樣做。


這里有一個片段。請注意,滑塊尺寸、邊距等可能看起來有所不同,因為此視口具有另一種大小。


var slideIndex = 1;

showDivs(slideIndex);


function showDivs(n) {

    var i;

    var x = document.getElementsByClassName("mySlides");

    slideIndex += n;

    

  if (slideIndex > x.length) {

      slideIndex = 1;

    }


  if (slideIndex < 1) {

      slideIndex = x.length;

    }


  if (n == 1){

    x[slideIndex-1].style.animationName = "MoveLeft";

  }else if (n == -1){

    x[slideIndex-1].style.animationName = "MoveRight";

  }


  for (i = 0; i < x.length; i++) {

    x[i].style.display = "none";  

  }


    x[slideIndex-1].style.display = "block";  

}

 .mySlides {position: absolute;animation: MoveLeft 1s;animation-fill-mode: forwards; }

    

        .classname { animation-name: MoveRight;position: absolute;-animation-fill-mode: forwards;}

    

    @keyframes MoveLeft {

      0%   {position: absolute; margin-top: 50px; margin-left: 62.5%; width: 150px; height: 200px;}

      100% {position: absolute; margin-left: 40%; width: 300px; height: 400px;}

      to  {position: absolute; margin-left: 40%; width: 20%; height: auto;}

    }

    

    @keyframes MoveRight {

      0%   {position: absolute; margin-top: 50px; margin-left: 25%; width: 150px; height: 200px;}

      100% {position: absolute; margin-left: 40%; width: 300px; height: 400px;}

      to  {position: absolute; margin-left: 40%; width: 20%; height: auto;}

    }

 <div style="position: absolute; margin-top: 5%; margin-left: 5%; width: 90%; height: 300px;">

            <div style="position: relative; width: 100%; height: 100%;">

                <div style="position: absolute; margin-top: 50px; margin-left: 25%; width: 20%; height: auto;"><img  id="BackaImage" onclick=" showDivs(-1);" src="https://dummyimage.com/150x200/FF0000/FF0000"></div>

                <img class="mySlides" id="unique" src="https://dummyimage.com/300x400/000/fff">

                <img class="mySlides" id="unique"  src="https://dummyimage.com/300x400/ff00ff/2d3bfc">

                <img class="mySlides" id="unique"  src="https://dummyimage.com/300x400/FF0000/FF00">

                <div style="position: absolute; margin-top: 50px; margin-left: 62.5%; width: 20%; height: auto;"><img onclick="showDivs(+1);" src="https://dummyimage.com/150x200/FF0000/FF0000"></div>

            </div>

        </div>


查看完整回答
反對 回復 2022-08-04
  • 1 回答
  • 0 關注
  • 116 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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