HTML5 3D展示特效是一種重要的網(wǎng)頁設(shè)計(jì)技術(shù),它可以讓網(wǎng)頁元素立體化,增強(qiáng)用戶體驗(yàn)。以下是一些常用的HTML5 3D展示特效代碼,供大家參考。
第一種特效代碼:
<div class="box"> <div class="front"> <h2>前面</h2> </div> <div class="back"> <h2>后面</h2> </div> <div class="left"> <h2>左邊</h2> </div> <div class="right"> <h2>右邊</h2> </div> <div class="top"> <h2>上面</h2> </div> <div class="bottom"> <h2>下面</h2> </div> </div> .box { transform-style: preserve-3d; transition: 1s; } .box:hover { transform: rotateY(180deg); } .front, .back, .left, .right, .top, .bottom { position: absolute; width: 200px; height: 200px; background-color: #ccc; border: 1px solid #333; } .front { transform: translateZ(100px); } .back { transform: translateZ(-100px); } .left { transform: rotateY(-90deg) translateZ(100px) translateX(-100px); } .right { transform: rotateY(90deg) translateZ(100px) translateX(100px); } .top { transform: rotateX(90deg) translateZ(100px) translateY(-100px); } .bottom { transform: rotateX(-90deg) translateZ(100px) translateY(100px); }第二種特效代碼:
<div class="box"> <div class="front"> <h2>前面</h2> </div> <div class="back"> <h2>后面</h2> </div> </div> .box { perspective: 1000px; transform-style: preserve-3d; } .front, .back { position: absolute; width: 200px; height: 200px; background-color: #ccc; border: 1px solid #333; transform-origin: center center; transition: 1s; } .back { transform: rotateY(180deg); } .box:hover .front { transform: rotateY(-180deg); } .box:hover .back { transform: rotateY(0deg); }以上就是兩種常用的HTML5 3D展示特效代碼,希望對(duì)大家有所幫助。