02月27, 2019

滚动的DOM边框

效果:

代码:

<!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>

本文链接:http://blog.pyzy.net/post/shine.html

-- EOF --

Comments