有时候,我们的产品交互上需要一些特别的效果,比如一个可编辑区域往往会添加一些动态描边效果,那么下面这个可能不失为一个不错的备选方案。
废话不说,直接上效果:
代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<style>
.box{
position: relative;
width:128px;
height: 128px;
1overflow: hidden;
}
.content {
position: absolute;
left:1px;
top:1px;
right:1px;
bottom:1px;
background:#fff;
}
.box:after{
content:'';
position: absolute;
z-index: -1;
left:0;
bottom:0;
top:1px;
right:1px;
background: repeating-linear-gradient(135deg, transparent, transparent 3px, #000 3px, #fff 8px);
animation: shine 1s infinite linear;
}
.box:before{
content:'';
position: absolute;
z-index: -1;
left:1px;
bottom:1px;
top:0;
right:0;
background: repeating-linear-gradient(135deg, transparent, transparent 3px, #fff 3px, #000 8px);
animation: shine2 1s infinite linear;
}
@keyframes shine {
0% { background-position: -1px -1px;}
100% { background-position: -12px -12px;}
}
@keyframes shine2 {
0% { background-position: -12px -12px;}
100% { background-position: -1px -1px;}
}
</style>
</head>
<body>
<div class="box">
<div class="content">内容占位</div>
</div>
</body>
</html>
Comments
可以发邮件 huzunjie@pyzy.net 或移步到 https://github.com/huzunjie/blog.pyzy.net/issues 评论交流。