首页 > 解决方案 > 如何从无显示淡入淡出到显示块?

问题描述

display: none如何在使用和使用display: blockjavascript时淡入我的弹出窗口?

另外,我想知道我应该如何将它用于图片滑块。我希望弹出窗口在我关闭它时淡入淡出,并且我希望在单击下一张照片时在图片之间进行过渡。

“modal”是弹出窗口,“mySlides”是照片。

var slideIndex;
var mySlides;

function openModal(modalName, myModalSlides) {
    document.getElementById(modalName).style.display = "block";
    document.getElementById(modalName).fadeIn();  //???
    mySlides = document.getElementById(myModalSlides);
}

function closeModal(modalName) {
    document.getElementById(modalName).style.display = "none"; 
    document.getElementById(modalName).fadeOut(); //???
    mySlides = null; 
}

function plusSlides(index) {
    showSlides(slideIndex += index);
    Element.style.opacity = 1;
}

function currentSlide(index) {
    showSlides(slideIndex = index);
}


function showSlides(index) {
    var i;
    if (index > mySlides.childElementCount) { slideIndex = 1 } 
    for (i = 0; i < mySlides.childElementCount; i++) { 
        mySlides.children[i].style.display = "none";
    }
    mySlides.children[slideIndex - 1].style.display = "block";
}

标签: javascriptcssanimationpopup

解决方案


推荐阅读