.shine-animate { z-index: 1; position: relative; overflow: hidden; } .shine-animate::after{ content: ''; z-index: -1; background-color: hsla(236, 32%, 26%, 0.2); position: absolute; top: -50%; bottom: -50%; left: 0; right: 0; animation: shine 2.5s infinite; } @keyframes shine { from { transform: translate3d(-525%, 0, 0) rotate(35deg); } to { transition: transform 0.45s ease-in-out; transform: translate3d(200%, 0, 0) rotate(35deg); } } .pulse-animate { z-index: 1; position: relative; outline: none; } .pulse-animate::before { content: ''; z-index: -1; position: absolute; top: 0; bottom: 0; left: 0; right: 0; border: 3px solid hsl(236, 32%, 26%); animation: pulse 1s infinite; } @keyframes pulse{ from { transform-origin: center; transform: scale(1); } to { transition: all 0.75s ease-in-out; transform-origin: center; transform: scale(1.5); opacity: 0; } } .ripple-animate { overflow: hidden; position: relative; } .ripple-animate::after{ content: ''; position: absolute; width: 100%; padding-top: 100%; background: transparent; border-radius: 50%; left: 50%; top: 50%; transform: translate(-50%,-50%); animation: ripple 0.6s; } @keyframes ripple{ from { transform:translate(-50%,-50%) scale(0); /**由于我们默认写了变换属性,所以这里要补上translate(-50%,-50%),不然就会被替换了**/ background: rgba(0,0,0,.25); } to { transform:translate(-50%,-50%) scale(1); background: transparent; } } @keyframes moveUp { from { transform: translateY(10px) scale(1); } to { transform: translateY(-10px) scale(1.2); } } @keyframes moveRight { from { transform: translateX(-5px); } to { transform: translateX(0); } } .move-right { animation: moveRight 1s infinite; } .move-left { animation: moveLeft 1s infinite; } @keyframes moveLeft { from { transform: translateX(0); } to { transform: translateX(5px); } }