我想在我的计算机(本地)中重新创建一个CSS动画,但它不起作用,当我在Codepen中尝试使用它的代码时,我做错了什么?
以下是代码:https://codepen.io/jvera/pen/gXxgXx
{
background: none;
border: 0;
box-sizing: border-box;
box-shadow: inset 0 0 0 2px #f45e61;
color: #f45e61;
font-size: inherit;
font-weight: 700;
margin: 1em;
padding: 1em 2em;
text-align: center;
text-transform: capitalize;
vertical-align: middle;
}
.draw {
overflow: hidden;
position: relative;
}
.draw::before, .draw::after {
content: '';
box-sizing: border-box;
position: absolute;
border: 2px solid transparent;
width: 0;
height: 0;
}
.draw::before {
top: 0;
left: 0;
border-top-color: #60daaa;
border-right-color: #60daaa;
animation: border 2s infinite;
}
.draw::after {
bottom: 0;
right: 0;
animation: border 2s 1s infinite, borderColor 2s 1s infinite;
}
@keyframes border {
0% {
width: 0;
height: 0;
}
25% {
width: 100%;
height: 0;
}
50% {
width: 100%;
height: 100%;
}
100% {
width: 100%;
height: 100%;
}
}
@keyframes borderColor {
0% {
border-bottom-color: #60daaa;
border-left-color: #60daaa;
}
50% {
border-bottom-color: #60daaa;
border-left-color: #60daaa;
}
51% {
border-bottom-color: transparent;
border-left-color: transparent;
}
100% {
border-bottom-color: transparent;
border-left-color: transparent;
}
}

<center><h2 class="draw">Titulo</h2><center>
&#13;
我创建了两个文件并将它们放入文件夹中,当我运行HTML文件时,我看不到动画效果(如演示)所以,我该怎么办?为什么我没有看到结果?
感谢。
答案 0 :(得分:2)
我不知道你的HTML&amp; CSS技巧,但也许你在样式表的链接上做错了:
<link rel="stylesheet" href="styles.css">
一定要核心设置路径(看一下这个例子:External CSS),也许可以一瞥HTML的基础知识,以防万一?
另外,检查路径是相对路径还是绝对路径:
相对路径:
绝对路径:
请参阅Full reference about the paths。
希望我帮助过。
答案 1 :(得分:0)
尝试添加-WebKit-keyframes功能。它可能是您的浏览器。 Link to how to do it