gpt4 book ai didi

css - 使用 :hover to trigger @keyframes animation when the element uses multiple animations

转载 作者:太空宇宙 更新时间:2023-11-03 18:22:53 25 4
gpt4 key购买 nike

我有一组图标,它们从页面中心过渡到一个设定点,然后保持在那里。我想要做的是将它们设置为过渡以具有更粗的边框并在我将鼠标悬停在其中一个上时缩放到 130x130px,但只出现初始动画

CSS:

.iconborder {
border-width: 5px;
border-style: solid;
border-radius: 100em;
border-color: white;
}

.iconborder:hover {animation-name: icongrow; animation-duration: 0.2s; animation-timing-function: cubic-bezier;}

@keyframes icongrow {
0% {
border-width: 5px;
width: 100px;
height: 100px;
}

100% {
border-width: 10px;
width: 130px;
height: 130px;
}
}

#FTPSlideOut
{
position: fixed;
width: 100px;
height: 100px;
left: 50%;
top: 50%;
margin-left: -50px;
margin-top: -50px;
z-index: 6;
visibility: hidden;

animation-name: FTPSlideOut;
animation-duration: 0.4s;
animation-timing-function: cubic-bezier;
animation-delay: 1s;
animation-fill-mode: forwards;

}

@keyframes FTPSlideOut {
0% {
transform: translate(0px, 0px);
visibility: visible;
}

100% {
transform: translate(-300px, -150px);
visibility: visible;
}
}

HTML:

    <body style="background-color:#D4D4D4;height:100%;width:100%">
<img id="SlideUp" class="dropshadow" src="picCenterDotFinalwText.png">
<a href="/net2ftp"><img id="FTPSlideOut" class="dropshadow iconborder" src="FTP.png"></a>
<img id="PicturesSlideOut" class="dropshadow iconborder" src="Pictures.png">
<img id="VideosSlideOut" class="dropshadow iconborder" src="Videos.png">
<img id="MusicSlideOut" class="dropshadow iconborder" src="Music.png">
<img id="DocumentsSlideOut" class="dropshadow iconborder" src="Documents.png">
<a href="https://www.gmail.com"><img id="EmailSlideOut" class="dropshadow iconborder" src="Email.png"></a>
</body>

有什么线索吗?

最佳答案

我不确定您为什么仅将关键帧用于简单的悬停动画。您可以只为该动画使用 css3 转换

看演示

@-webkit-keyframes icongrow {
0%{
border-width: 5px;
width: 100px;
height: 100px;
}

100% {
border-width: 10px;
width: 130px;
height: 130px;
border-color:#ccc;
}
}

.iconborder{
text-align:center;
border: solid 5px #fff; /* use shorthand */
border-radius: 100em;

/* customize */
-webkit-transition : border 0.2s linear;


/*-webkit-animation-duration: 0.2s;*/

}

.iconborder:hover{
border: 10px solid #fff;
width: 130px;
height: 130px;

cursor:pointer;
/* -webkit-animation-name: icongrow;
-webkit-animation-fill-mode: forwards;*/
}



@-webkit-keyframes FTPSlideOutAnimate {
0%{
opacity:0;
-webkit-transform: translate(0,0);
}

100% {
opacity:1;
-webkit-transform: translate(-300px, -150px);
}
}



#FTPSlideOut{
position: fixed;
width: 100px;
height: 100px;
left: 50%;
top: 50%;
margin-left: -50px;
margin-top: -50px;
z-index: 6;

/* customize */
opacity:0.1;
-webkit-transition: -webkit-transform 1s ease-in,
opacity 0.5s linear;
}

#FTPSlideOut:hover{
-webkit-transform: translate(-300px, -150px);
opacity:1;

/*-webkit-animation: FTPSlideOutAnimate 0.2s linear;
-webkit-animation-fill-mode: forwards; */
}

http://jsfiddle.net/phcba/2/

在那个 fiddle 中,您可以取消注释关键帧属性,只是为了检查并查看如果没有为您的悬停效果正确完成使用关键帧时动画有多糟糕

我也不确定#FTPSlideOut 在您的网站上的位置和显示方式,所以我在该演示中几乎看不到它。我使用了 Opacity 而不是 visibilty,你需要根据你的情况修改它。

有关 CSS3 转换的更多信息: http://css-tricks.com/almanac/properties/t/transition/

干杯

关于css - 使用 :hover to trigger @keyframes animation when the element uses multiple animations,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21471125/

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