具体效果如下:
实现代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>文件扫描动效</title>
</head>
<style>
.code-bg{
position: relative;
height: 179px;
width: 179px;
margin: 0px auto;/*此处为了居中*/
text-align: center;
background: url(img/code-bg.png) center top no-repeat;
border: 1px solid #eee;
}
.code-bg img{
position: absolute;
top: 10px; left: 20px;
z-index: 1;
height: 160px; width: 160px;
}
.line{
position: absolute;
top: 5px;
left: -60px;
z-index: 2;
height: 3px;
width: 360px;
background: url(img/line.png) no-repeat;
/*动画效果*/
animation: myScan 2s infinite alternate;
-webkit-animation: myScan 2s infinite alternate;
}
@keyframes myScan{
from { top:5px; }
to { top: 170px; }
}
-webkit-@keyframes myScan{
from { top:5px; }
to { top: 170px; }
}
</style>
<body>
<div class="code-bg">
<div class="line"></div>
<img src="img/1.jpg" alt="">
</div>
</body>
</html>