我目前正试图让#InnerImage的背景图像淡出。下面是#InnerImage代码:背景图像的不透明度动画
<div id="InnerImage" style="background-image:url('imgurl.com'););background-repeat:no-repeat;background-position:50% 0%;">
下面是我使用的代码:(?)
#OuterImage #InnerImage {
-webkit-animation: 3s ease 0s normal forwards 1 fadein;
animation: 3s ease 0s normal forwards 1 fadein;
}
@keyframes fadein{
0% { opacity:0; }
66% { opacity:0; }
100% { opacity:1; }
}
@-webkit-keyframes fadein{
0% { opacity:0; }
66% { opacity:0; }
100% { opacity:1; }
}
我运行到哪里代码正在尽一切其他儿童问题的div #InnerImage中也会淡出,但我只希望背景图像淡入淡出。
我有两个问题:
1)我看过,这是不可能的背景图像不透明度的变化,上面的代码正在执行。有没有解决这个问题的方法?
2)我该怎么做才能让图像淡入后,在无限循环中淡出?
[编辑]
#OuterImage #InnerImage{
-webkit-animation: 3s ease 0s normal forwards 1 fadein;
animation: 3s ease 0s normal forwards 1 fadein;
animation-iteration-count: infinite;
}
@keyframes fadein{
0% { opacity:0; }
66% { opacity:0; }
100% { opacity:1; }
}
@-webkit-keyframes fadein{
0% { opacity:0; }
66% { opacity:0; }
100% { opacity:1; }
}
#OuterImage #InnerImage::before {
background: url('imgurl.com') no-repeat center left;
content: "";
position: absolute;
/* the following makes the pseudo element stretch to all sides of host element */
top: 0;
right: 0;
bottom: 0;
left: 0;
transition: opacity 1s ease 2s;
z-index: 1;
}
#OuterImage #InnerImage {
position: relative;}
#OuterImage #InnerImage * {
position: relative;
z-index: 2;
}
#OuterImage #InnerImage
文本内容不褪色所以你的问题回答?如果是,请选择最佳答案。如果不是,请评论缺少的最佳解决方案。 – connexo
对不起,我正在看一看! – lolikols