HTML3D摩天輪相冊是一款非常實用的相冊代碼,可以在網(wǎng)頁中展示美麗的摩天輪相片,給網(wǎng)頁帶來更加美觀的呈現(xiàn)。下面是該代碼的實現(xiàn)方式。
<html> <head> <style> .carousel { border: 1px solid #888; width: 500px; height: 300px; margin: 0 auto; position: relative; perspective: 800px; } .carousel figure { display: block; position: absolute; width: 100%; height: 100%; margin: 0; left: 0; top: 0; text-align: center; transform-origin: center center -300px; } .carousel figure:nth-child(1) { transform: rotateY(0deg); } .carousel figure:nth-child(2) { transform: rotateY(40deg); } .carousel figure:nth-child(3) { transform: rotateY(80deg); } .carousel figure:nth-child(4) { transform: rotateY(120deg); } .carousel figure:nth-child(5) { transform: rotateY(160deg); } .carousel figure:nth-child(6) { transform: rotateY(200deg); } .carousel figure:nth-child(7) { transform: rotateY(240deg); } .carousel figure:nth-child(8) { transform: rotateY(280deg); } .carousel figure:nth-child(9) { transform: rotateY(320deg); } .carousel img { max-width: 100%; height: auto; } </style> </head> <body> <div class="carousel"> <figure><img src="carousel/1.jpg" alt="摩天輪1號"></figure> <figure><img src="carousel/2.jpg" alt="摩天輪2號"></figure> <figure><img src="carousel/3.jpg" alt="摩天輪3號"></figure> <figure><img src="carousel/4.jpg" alt="摩天輪4號"></figure> <figure><img src="carousel/5.jpg" alt="摩天輪5號"></figure> <figure><img src="carousel/6.jpg" alt="摩天輪6號"></figure> <figure><img src="carousel/7.jpg" alt="摩天輪7號"></figure> <figure><img src="carousel/8.jpg" alt="摩天輪8號"></figure> <figure><img src="carousel/9.jpg" alt="摩天輪9號"></figure> </div> </body> </html>
該代碼的實現(xiàn)原理是使用了CSS 3的transform屬性。設定摩天輪的中心點為800像素的空間,摩天輪上的照片主要通過設置transform: rotateY(角度),使得相片沿著Y軸旋轉(zhuǎn)。