[html] view plain copy
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/htmlcharset=utf-8" />
<title>无标题文档</title>
<style>
@keyframes warn {
0% {
transform: scale(0)
opacity: 0.0
}
25% {
transform: scale(0)
opacity: 0.1
}
50% {
transform: scale(0.1)
opacity: 0.3
}
75% {
transform: scale(0.5)
opacity: 0.5
}
100% {
transform: scale(1)
opacity: 0.0
}
}
@-webkit-keyframes "warn" {
0% {
-webkit-transform: scale(0)
opacity: 0.0
}
25% {
-webkit-transform: scale(0)
opacity: 0.1
}
50% {
-webkit-transform: scale(0.1)
opacity: 0.3
}
75% {
-webkit-transform: scale(0.5)
opacity: 0.5
}
100% {
-webkit-transform: scale(1)
opacity: 0.0
}
}
.container {
position: relative
width: 40px
height: 40px
border: 1px solid #000
}
/* 保持大小不变的小圆圈 */
.dot {
position: absolute
width: 6px
height: 6px
left: 15px
top: 15px
-webkit-border-radius: 20px
-moz-border-radius: 20px
border: 2px solid red
border-radius: 20px
z-index: 2
}
/* 产生动画(向外扩散变大)的圆圈 */
.pulse {
position: absolute
width: 24px
height: 24px
left: 2px
top: 2px
border: 6px solid red
-webkit-border-radius: 30px
-moz-border-radius: 30px
border-radius: 30px
z-index: 1
opacity: 0
-webkit-animation: warn 3s ease-out
-moz-animation: warn 3s ease-out
animation: warn 3s ease-out
-webkit-animation-iteration-count: infinite
-moz-animation-iteration-count: infinite
animation-iteration-count: infinite
}
</style>
</head>
<body>
<div class="container">
<div class="dot"></div>
<div class="pulse"></div>
</div>
</body>
</html>
1、首先新建一个html空白文档,取名字叫做css3动画,保存一下。
2、然后写html结构,只需要一个div元素即可,class名字叫做img
3、设置其边框为不同的颜色,边框宽度设置成100px。
4、因为是圆环,所以我们用到了css3的圆角效果,设置圆角为50%,也就是border-radius:50%,看一下效果。
5、接下来就是关键的步骤了,也就是添加动画效果。输入以下代码
6、来看一下最后的效果,还是不错的。
1、首先打开sublime text编辑器,新建一个html文件,里面写入一个p标签:
2、然后设置p标签的样式,这里先设置一个边框,然后设置圆角边框,主要使用CSS3属性border-radius属性定义圆角效果。其中的数值为参数length是浮点数和单位标识符组成的长度值,不可为负值,这里圆角的值越大,圆角的弧度也越大:
3、最后打开浏览器,就可以看到圆角边框了: