在此页面上,我将视频下的一些元素设置为使用 CSS 在 15 秒后淡入。
问题是,在元素淡入之前,视频下方的背景是灰色的。
如何在我的元素完成褪色之前将灰色背景更改为白色(或者实际上是#F3F8FC)?我似乎找不到合适的 CSS 选择器来更改它。这是我正在使用的 CSS - 需要弄清楚如何更改隐藏元素背后的颜色:
/* make keyframes that tell the start state and the end state of our object */
@-webkit-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@-moz-keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.enroll {
opacity:0; /* make things invisible upon start */
-webkit-animation:fadeIn ease-in 1; /* call our keyframe named fadeIn, use animattion ease-in and repeat it only 1 time */
-moz-animation:fadeIn ease-in 1;
animation:fadeIn ease-in 1;
-webkit-animation-fill-mode:forwards; /* this makes sure that after animation is done we remain at the last keyframe value (opacity: 1)*/
-moz-animation-fill-mode:forwards;
animation-fill-mode:forwards;
-webkit-animation-duration:1s;
-moz-animation-duration:1s;
animation-duration:1s;
}
.enroll {
-webkit-animation-delay: 15s;
-moz-animation-delay: 15s;
animation-delay: 15s;
}
干杯。
最佳答案
Javascript 解决方案
您可以使用 javascript 代替 CSS。
function fadeIn(){
//code to fadeIn...
}
在 HTML 中你添加元素
<div id="bg" onload="setTimeout('fadeIn()', 15000)"></div>
CSS 解决方案
您可以使用背景:(这里有属性,例如颜色);
。
下面是示例:
背景:白色;
试试这个:
@keyframes fadeIn { from { opacity:0;background:(color-1); } 到 { 不透明度:1;背景:(颜色 2); }
关于css - 如何更改背景元素的CSS?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36279409/