css3动态背景图片代码实例

2018-2-4 09:52| 作者: admin| 查看: 967| 评论: 0|来自: 蚂蚁部落

本章节分享一段代码实例,它实现了动态背景图片效果。

代码实例如下:

[HTML] 纯文本查看 复制代码运行代码
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="author" content="http://www.softwhy.com/" />
<title>蚂蚁部落</title>
<style type="text/css">
.pic {
  width: 1600px;
  height: 500px;
  overflow: hidden;
  position: relative;
}
.pic .img {
  background: url(demo/CSS/img/dongtai.jpg) no-repeat center center;
  height: 100%;
  animation: mymove 10s infinite;
  -webkit-animation: mymove 10s infinite;
}
@keyframes mymove {
  0% {
    background-position: center;
  }
  25% {
    background-position: top;
  }
  50% {
    background-position: center;
  }
  75% {
    background-position: bottom;
  }
  100% {
    background-position: center;
  }
}
.pic img {
  position: relative;
  animation: mymove2 10s infinite;
  -webkit-animation: mymove2 10s infinite;
}
@keyframes mymove2 {
  0% {
    top: -200px;
  }
  25% {
    top: 0;
  }
  50% {
    top: -200px;
  }
  75% {
    top: -400px;
  }
  100% {
    top: -200px;
  }
}
</style>
</head>
 
<body>
<div class="wrap">
  <div class="pic">
    <div class="img"></div>
  </div>
</div>
</body>
</html>

鲜花

握手
1

雷人

路过

鸡蛋

刚表态过的朋友 (1 人)

最新评论

返回顶部