正文 1326字数 16,218阅读


<style>@keyframes flowing-border { 0% { box-shadow: inset 0 0 0 2px #ff0000; } 25% { box-shadow: inset 0 0 0 2px #00ff00; } 50% { box-shadow: inset 0 0 0 2px #0000ff; } 75% { box-shadow: inset 0 0 0 2px #ffff00; } 100% { box-shadow: inset 0 0 0 2px #ff00ff; } } .flowing-box { /* 其他样式 */ animation: flowing-border 5s linear infinite; } </style>
Run code
Cut to clipboard


    效果:
    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <style> .flowing-box { width: 200px; height: 150px; background-color: #fff; position: relative; } @keyframes flowing-border { 0% { box-shadow: inset 0 0 0 2px #ff0000; } 25% { box-shadow: inset 0 0 0 2px #00ff00; } 50% { box-shadow: inset 0 0 0 2px #0000ff; } 75% { box-shadow: inset 0 0 0 2px #ffff00; } 100% { box-shadow: inset 0 0 0 2px #ff00ff; } } .flowing-box { /* 其他样式 */ animation: flowing-border 5s linear infinite; } </style> </head> <body> <div class="flowing-box">这是一个box</div> </body> </html>
    Run code
    Cut to clipboard