【发布时间】:2013-10-20 14:41:49
【问题描述】:
我想在我的网站上尽可能只使用 HTML5 和 CSS3。
我正在尝试为我的联系按钮上的文本设置动画。更具体地说,我希望它每 20 秒更改一次颜色并变为 font-weight: bolder 4 秒。
现在它确实可以切换颜色,但在 Chrome、Safari 和 Opera 中不会变粗。它在 Firefox 和 IE 中运行良好。
这是我正在使用的 CSS:
#contact {
position: fixed;
margin-top: 63px;
margin-left: 680px;
width: 250px;
height: 55px;
transform:rotate(-36.87deg);
z-index: 20 !important;
font-size: 24px;
line-height: 55px;
text-align: center;
text-decoration: none;
color: #FFFFFF;
transition: all 1s ease;
animation-name: alarmlight;
animation-iteration-count: infinite;
animation-duration: 20s;
}
@keyframes alarmlight {
0% { color: #FFFFFF; font-weight: normal; }
80% { color: #FFFFFF; font-weight: normal; }
85%{ color: #00F; font-weight: bolder; }
90% { color: #F00; font-weight: bolder; }
95% { color: #00F; font-weight: bolder; }
100% { color: #F00; font-weight: bolder; }
}
a#contact:hover {
color: #FFF101 !important;
font-weight:bold !important;
animation-name:none;
transition: all 1s ease;
transform: translate(18px,-18px) rotate(-36.87deg);
}
检查Here 以查看它的实际效果。
更新:还创建了一个简单的jsfiddle 来显示其核心问题。
更新:更新了这篇文章中的 CSS 以反映我在当前状态下使用的代码。
【问题讨论】:
-
我读了这篇文章,这是一个不同的问题。我没有要求平稳过渡。如果它只是切换到粗体 4 秒,然后再变为非粗体 16 秒,它就可以了。另外,我没有使用数值。我只使用正常和大胆。据我所知,这应该是可能的。
-
@Juhana 我明白你为什么要更改
font-weight:bolder的东西,我不知道该怎么做。只是出于好奇,你为什么把我帖子底部的提前致谢部分去掉? -
“提前致谢”和签名被认为是无关的噪音。请参阅here 进行讨论。
-
提供现场演示! jsfiddle.net