gpt4 book ai didi

jquery - Webkit 动画不会从无到有淡化

转载 作者:行者123 更新时间:2023-11-28 17:36:36 26 4
gpt4 key购买 nike

我知道我没有正确使用 CSS 动画,但我正在努力寻找一个 web-kit 转换来满足我的需要。我需要图像 (enter_button.png) 以 0% 的不透明度加载,然后在 3 秒后淡入纯色 100% 图像。我目前的代码是,

HTML:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>denby</title>
<link href="style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="wrapper_index">
<div id="enter_button">
<img src="images/enter_button.png" width="138" height="50" class="withfadeout" />
</div>
</div>
</body>
</html>

CSS:

@charset "utf-8";
.withfadeout {
-webkit-transition: all 2s ease-in-out;
-moz-transition: all 2s ease-in-out;
-ms-transition: all 2s ease-in-out;
-o-transition: all 2s ease-in-out;
transition: all 2s ease-in-out;
}
.withfadeout:hover {
-webkit-opacity: 0.25;
-moz-opacity: 0.25;
opacity: 0.25;
}
#wrapper_index {
height: 686px;
width: 1024px;
background-color: #000;
margin-right: auto;
margin-left: auto;
margin-top: 50px;
background-image: url(images/entry_image-01.png);
background-repeat: no-repeat;
position: relative;
}
#enter_button {
width: 140px;
position: absolute;
left: 431px;
top: 413px;
}

如有任何帮助,我们将不胜感激。

最佳答案

您可以使用 CSS3 动画来实现这一点。

img { /* using generic img tag selector only for demo, change selector as appropriate */
opacity: 0;
-webkit-animation: load 3s 3s linear forwards;
-moz-animation: load 3s 3s linear forwards;
animation: load 3s 3s linear forwards; /* adding mode as forwards makes the animation to retain its state as at the last keyframe */
/* syntax is animation: animation-name animation-duration animation-delay animation-timing-function animation-fill-mode */
}
@-webkit-keyframes load {
from {
opacity: 0;
}
/* starts at opacity 0 */
to {
opacity: 1;
}
/* ends at opacity 1 */
}
@-moz-keyframes load {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes load {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
<div id="wrapper_index">
<div id="enter_button">
<img src="https://www.google.com.sg/intl/en_ALL/images/srpr/logo11w.png" width="138" height="50" class="withfadeout" />
</div>
</div>

注意:上述代码中的 3 秒延迟意味着动画本身将在 3 秒后开始,因此图像变为 100% 实体总共需要 6 秒。如果不需要延迟,可以将其删除。

进一步阅读: MDN - CSS3 Animation Spec

关于jquery - Webkit 动画不会从无到有淡化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24988470/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com