javascript - 如何从无显示淡入淡出到显示块?
问题描述
display: none
如何在使用和使用display: block
javascript时淡入我的弹出窗口?
另外,我想知道我应该如何将它用于图片滑块。我希望弹出窗口在我关闭它时淡入淡出,并且我希望在单击下一张照片时在图片之间进行过渡。
“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";
}
解决方案
推荐阅读
- angular - 测量外部 API 调用的时间:以角度处理异步
- angular - 学习 Angular 以及决定主屏幕 html 的因素
- redis - 在 Redis 中提高写入性能的选项
- python - 从数据库访问与时间戳对应的值会返回一个 Series 而不是单个 numpy.float64 值
- php - 如何在单个 cURL 请求中获取和发布信息?
- kubernetes - Kubernetes pod 无法解析主机?
- php - 我目前遇到 PHP 致命错误的问题
- c# - 将 web-API 注册字段从电子邮件更改为电话号码
- cytoscape.js - Cytoscape 链接删除支持
- python - ANTLR4 python 语法错误与设置示例