CSS 3D技術在網頁設計中廣泛應用,可以為網頁增添立體感和動態效果。以下是一些CSS 3D網頁特效素材,可以為網頁設計提供靈感和參考。
/* 立方體翻轉效果 */ .cube { position: relative; width: 200px; height: 200px; transform-style: preserve-3d; transition: transform 1s; } .cube:hover { transform: rotateY(180deg); } .cube .side { position: absolute; width: 200px; height: 200px; background-color: #f00; text-align: center; } .cube .side.front { transform: translateZ(100px); } .cube .side.back { transform: translateZ(-100px) rotateY(180deg); } .cube .side.left { transform: rotateY(-90deg) translateX(-100px); } .cube .side.right { transform: rotateY(90deg) translateX(100px); } .cube .side.top { transform: rotateX(-90deg) translateY(-100px); } .cube .side.bottom { transform: rotateX(90deg) translateY(100px); } /* 3D滑塊效果 */ .slider { position: relative; width: 300px; height: 200px; background-color: #f00; perspective: 500px; } .slider .item { position: absolute; width: 100%; height: 100%; background-color: #0f0; transform-style: preserve-3d; transition: transform 1s; } .slider .item.left { transform: rotateY(90deg) translateZ(100px); } .slider .item.right { transform: rotateY(-90deg) translateZ(100px); } .slider:hover .item.left { transform: rotateY(0) translateZ(0); } .slider:hover .item.right { transform: rotateY(0) translateZ(0); } /* 3D字體效果 */ .text { position: relative; font-size: 48px; text-transform: uppercase; color: #f00; letter-spacing: 2px; perspective: 500px; } .text:hover span { animation: spin 1s linear infinite; } .text span { display: inline-block; transform-origin: center; transition: transform 0.5s; } .text span:nth-child(1) { transform: rotateX(90deg) translateZ(24px); } .text span:nth-child(2) { transform: rotateY(-90deg) translateZ(24px); } .text span:nth-child(3) { transform: translateZ(24px); } .text span:nth-child(4) { transform: rotateY(90deg) translateZ(24px); } .text span:nth-child(5) { transform: rotateX(-90deg) translateZ(24px); } @keyframes spin { 0% { transform: rotateX(0) rotateY(0); } 100% { transform: rotateX(360deg) rotateY(360deg); } }
以上是一些常見的CSS 3D網頁特效素材,通過對其進行修改和組合,在網頁設計中可以實現更加豐富和創新的效果。