純CSS特效在網頁設計中經常使用,可以為網頁增添一些引人注目的效果和交互效果。這里為大家分享一些簡單的純CSS特效代碼。
/* 文字閃爍效果 */ @keyframes blink { 0% { opacity: 1; } 50% { opacity: .5; } 100% { opacity: 1; } } .blink { animation: blink 1s infinite; } /* 圖片翻轉效果 */ .flip-card { position: relative; width: 200px; height: 200px; margin: 20px 0; transform-style: preserve-3d; transition: transform .5s; } .flip-card:hover { transform: rotateY(180deg); } .flip-card-inner { position: relative; width: 100%; height: 100%; text-align: center; transition: transform .5s; transform-style: preserve-3d; } .flip-card:hover .flip-card-inner { transform: rotateY(180deg); } .flip-card-front, .flip-card-back { position: absolute; width: 100%; height: 100%; backface-visibility: hidden; } .flip-card-front { background-color: #fff; } .flip-card-back { transform: rotateY(180deg); background-color: #000; color: #fff; } /* 按鈕懸浮效果 */ .btn { display: inline-block; padding: 10px 30px; background-color: #fff; border: solid 1px #000; font-size: 20px; transition: all .3s; } .btn:hover { background-color: #000; color: #fff; } /* 背景圖像放大效果 */ .background { background-image: url('xxx.jpg'); background-size: cover; background-position: center; height: 400px; position: relative; } .background:before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; background-color: rgba(0, 0, 0, .5); opacity: 0; transition: opacity .3s; } .background:hover:before { opacity: 1; }
以上是一些簡單的純CSS特效代碼,可以根據需要進行調整和修改,實現更加個性化的效果。