CSS 旋转不起作用

标签 css

我正在测试一些 css 动画,但无法获取此元素:在旋转之前,有什么帮助吗?

http://jsfiddle.net/gespinha/hZjkp/5/

CSS

.footerLink{
    padding:20px;
    background:#000;
    color:#fff;
}
.footerLink:before{
    content:'ABC';
    margin-right:15px;
    -webkit-animation: footerHoverOff .5s ease both;
    -moz-animation: footerHoverOff .5s ease both;
    animation: footerHoverOff .5s ease both;
}
.footerLink:hover:before{
    -webkit-animation: footerHoverOn .5s ease both;
    -moz-animation: footerHoverOn .5s ease both;
    animation: footerHoverOn .5s ease both;
}
@-webkit-keyframes footerHoverOn{ to { -webkit-transform: scale(1.5) rotate(360deg); } }
@-moz-keyframes footerHoverOn{ to { -moz-transform: scale(1.5) rotate(360deg); } }
@keyframes footerHoverOn{ to { transform: scale(1.5) rotate(360deg); } }
@-webkit-keyframes footerHoverOff{ from { -webkit-transform: scale(1.5) rotate(360deg); } }
@-moz-keyframes footerHoverOff{ from { -moz-transform: scale(1.5) rotate(360deg); } }
@keyframes footerHoverOff{ from { transform: scale(1.5) rotate(360deg); } }

最佳答案

伙计,这不是你处理 css 关键帧动画的方式。您将语法与转换混淆了。

使用关键帧动画:

.footerLink{
padding:20px;
background:#000;
color:#fff;
}
.footerLink:before{
    content:'ABC';
    margin-right:15px;
}
.footerLink:before:hover {
    animation: footerHover .5s;
}
@keyframes footerHover { 
    from { transform: scale(1.5) rotate(0deg); }
    to { transform: scale(1.5) rotate(360deg); } 
}

有过渡:

.footerLink{
    padding:20px;
    background:#000;
    color:#fff;
}
.footerLink:before{
    content:'ABC';
    margin-right:15px;
    transform: scale(1.5) rotate(0deg);
    transition: .5s;
}
.footerLink:before:hover {
    transform: scale(1.5) rotate(360deg);
}

关于CSS 旋转不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18667849/

相关文章:

javascript - Twitter Bootstrap nav collapse 点击隐藏

css - 在 React Native 中将 View 置于其他 View 之上

PHP 用于 HTML 元素,确定奇数/偶数,代码忽略背景图像

mysql - 当在数据库中删除某些内容时,如何更改其他记录以便记录的 id 发生变化

html - Chrome 中的等高 Flexbox 列

css - 为什么 Firefox 上的 Firebug 显示 "border-width: 0 1px 1px"而计算样式显示 1.1px?

javascript - 使用javascript动态生成的按钮

javascript - 使用 style=none 在 javascript 中隐藏链接在 IE 中不起作用

css - 在嵌套 Flexbox 中的 Flex 元素之间创建空间

CSS Cursor 代码 - 显然是错误的语法