搜索文档
首页
HTML/CSS
JavaScript
服务端开发
Java教程
移动端
数据库
当前位置:
首页
HTML/CSS
CSS 参考手册
CSS 参考手册
源代码
清空
点击运行
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>CSS background 属性动画示例- 基础教程(div.cn)</title> <style> .animated { width: 300px; height: 175px; background: url("/run/images/sun.png") no-repeat -50px -50px black; background-size: 10%; -webkit-animation: test 4s infinite; /* Chrome, Safari, Opera */ animation: test 4s infinite; } /* Chrome, Safari, Opera */ @-webkit-keyframes test { 50% { background-color: floralwhite; background-position: center; background-size: 40%; } } /* Standard syntax */ @keyframes test { 50% { background-color: floralwhite; background-position: center; background-size: 40%; } } </style> </head> <body> <p> <strong>警告:</strong>:CSS动画在Internet Explorer 9和更早版本中不起作用。</p> <p> <strong>注意</strong>:在所有单独的背景属性中,只有background-color,background-position和background-size属性在CSS中是可动画的。 有关详细信息,请参见CSS <a href="https://www.div.cn/css-reference/css-background-属性示例.html" target="_top">背景</a>速记属性。</p> <div class="animated"></div> </body> </html>
运行结果