本文介绍了通过css3动画和opacity透明度实现呼吸灯效果的方法,分享给大家,具体如下:
- <!DOCTYPE html>
- <html lang="en">
- <head>
-
- <meta charset="UTF-8">
- <title>呼吸灯</title>
- /*也可以通过加层罩,通过设置层罩透明度来实现亮度动画*/
- <style>
- body{
- background-color: black;
- }
- div{
- margin: 0 auto;
- margin-top: 200px;
- width: 300px;
- height: 300px;
- border-radius: 50%;
- background-color: yellow;
- box-shadow: 0 0 80px red;
- animation-name: light;
- animation-duration: 3s;
- animation-timing-function: linear;
- animation-iteration-count: infinite;
- animation-direction: alternate;
- }
- @keyframes light{
- from{
- opacity: 1;
- }
- to{
- opacity: 0.2;
- }
- }
- </style>
- </head>
- <body>
-
- <div></div>
- </body>
- </html>
-
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持w3xue。