<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>呼吸灯</title>
<style>
*{
box-sizing: border-box;
/* 所有盒子变成怪异盒子 */
}
div.article{
width: 250px;
height: 350px;
background-color: black;
margin:0 auto;
/* 当前块级元素水平居中 */
}
div.top{
width:250px;
height: 250px;
padding:20px;
/* 内边距 */
animation-name: outer;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div.text{
color: #fff;
text-align: center;
}
div#outer{
height: 100%;
border:5px solid #ccc;
border-radius: 50%;
/* 设置圆角边框属性 */
padding:20px;
animation-name: inner;
animation-duration: 5s;
animation-iteration-count: infinite;
animation-timing-function: linear;
}
div#inner{
height: 100%;
border:10px solid #fff;
border-radius: 50%;
}
@keyframes outer{
25%{
padding: 10px;
}
50%{
padding: 20px;
}
100%{
padding: 20px;
}
}
@keyframes inner{
25%{
padding: 30px;
}
50%{
padding: 20px;
}
75%{
padding: 32px;
}
100%{
padding: 20px;
}
}
</style>
</head>
<body>
<div class="article">
<div class="top">
<!--
外圆:
1.向外扩大10px
2.向内缩小10px
3.保持不动
内圆:
1.在外圆扩大的同时缩小10px
2.在外圆缩小的同时扩大10px
3.向内缩小12px
4.向外扩大12px
-->
<div id="outer">
<!-- 内圆的inner变小,外圆的outer的内边距变大 -->
<div id="inner"></div>
</div>
</div>
<div class="text">HI~</div>
</div>
</body>
</html>
呼吸灯案例css
最新推荐文章于 2024-04-24 14:34:29 发布