最近在學習前端開發,發現許多酷炫的特效都離不開純CSS的幫助。在這里,我將向大家介紹一些純CSS特效的實現方法,供大家參考和學習。
1. 動態背景色漸變
.gradient { background: linear-gradient(to right, #00C9FF , #92FE9D); background-size: 200% 200%; animation: gradientAnimation 2s ease infinite; } @keyframes gradientAnimation { 0% { background-position: left; } 100% { background-position: right; } }
2. 懸浮放大效果
.hover-scale { transition: transform .2s ease-in-out; } .hover-scale:hover { transform: scale(1.2); }
3. 3D卡片翻轉效果
.card-container { perspective: 1000px; } .card { position: relative; transition: transform .6s; transform-style: preserve-3d; } .card:hover { transform: rotateY(180deg); } .card-front, .card-back { position: absolute; backface-visibility: hidden; } .card-front { z-index: 2; } .card-back { transform: rotateY(180deg); }
4. 背景圖覆蓋文字效果
.overlay-text { position: relative; } .overlay-text:before { content: ""; position: absolute; top: 0; left: 0; background: rgba(0,0,0,.5); width: 100%; height: 100%; opacity: 0; transition: opacity .2s ease-in-out; } .overlay-text:hover:before { opacity: 1; }
5. 動態水波效果
.wave { transform-origin: center; animation: waveAnimation 1.5s linear infinite; } @keyframes waveAnimation { 0% { transform: translate(-50%, -50%) scale(1); } 100% { transform: translate(-50%, -50%) scale(1.5); opacity: 0; } }
以上就是我分享的純CSS特效實現方法,希望能對大家有所幫助。
上一篇純css實現給圖片加標簽
下一篇純css滾動焦點圖