如何在js平面中设置不透明度0到1
How to set opacity 0 to 1 in js plane
我有 carrusel 的照片,每张照片在加载时都具有不透明度 0,我不会用不透明度 0 到 1 进行转换
function opacityCarrusel() {
if (imagenEnsaladas.style.opacity < 1) {
imagenEnsaladas.style.opacity = +0.1;
}
}
setInterval(opacityCarrusel, 200);
我试过了,但总不透明度不再为 0,1
像这样重写
function opacityCarrusel(reset = false) {
if (typeof opacityCarrusel.opct === "undefined")
opacityCarrusel.opct = 0;
if (reset) opacityCarrusel.opct=0;
if (imagenEnsaladas.style.opacity < 1) {
opacityCarrusel.opct += 0.1;
imagenEnsaladas.style.opacity = opacityCarrusel.opct;
}
}
setInterval(opacityCarrusel, 200);
当你想为新图像使用此功能时,请使用重置选项。
我有 carrusel 的照片,每张照片在加载时都具有不透明度 0,我不会用不透明度 0 到 1 进行转换
function opacityCarrusel() {
if (imagenEnsaladas.style.opacity < 1) {
imagenEnsaladas.style.opacity = +0.1;
}
}
setInterval(opacityCarrusel, 200);
我试过了,但总不透明度不再为 0,1
像这样重写
function opacityCarrusel(reset = false) {
if (typeof opacityCarrusel.opct === "undefined")
opacityCarrusel.opct = 0;
if (reset) opacityCarrusel.opct=0;
if (imagenEnsaladas.style.opacity < 1) {
opacityCarrusel.opct += 0.1;
imagenEnsaladas.style.opacity = opacityCarrusel.opct;
}
}
setInterval(opacityCarrusel, 200);
当你想为新图像使用此功能时,请使用重置选项。