本篇內(nèi)容介紹了“怎么用css3實(shí)現(xiàn)照片墻效果”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
目前成都創(chuàng)新互聯(lián)公司已為千余家的企業(yè)提供了網(wǎng)站建設(shè)、域名、虛擬主機(jī)、網(wǎng)站托管、服務(wù)器托管、企業(yè)網(wǎng)站設(shè)計(jì)、寧武網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。
一張張照片散亂的撒在一起,鼠標(biāo)懸浮時(shí)旋轉(zhuǎn)放大并擺正,效果如下圖(所有圖片均來自網(wǎng)絡(luò)),主要使用到的css3屬性有:transition、transform(scale、rotateZ)、box-shadow以及z-index。

代碼如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
*{margin:0;padding:0;}
html,body{background:#eee;}
/*設(shè)置場(chǎng)景居中*/
.wall{width:1000px;height:700px;position:fixed;top:50%;margin-top:-350px;left:50%;margin-left:-500px;}
/*設(shè)置圖片絕對(duì)定位,方便設(shè)置放置的位置,并設(shè)置所有屬性的過渡時(shí)間為0.2s*/
img{position:absolute;display:block;max-width:300px;max-height:300px;padding:10px 10px 20px;background:#fff;border:1px solid #ddd;-webkit-transition:0.2s;}
/*鼠標(biāo)懸浮時(shí)設(shè)置大小放大到1.2倍,并擺正,即Z軸方向的旋轉(zhuǎn)角度為0*/
img:hover{-webkit-transform:scale(1.2) rotateZ(0);box-shadow:10px 10px 5px #555;z-index:2;}
/*設(shè)置每個(gè)照片的位置和旋轉(zhuǎn)角度*/
.img1{left:0;top:0;-webkit-transform:rotateZ(20deg);}
.img2{left:280px;top:0;-webkit-transform:rotateZ(5deg);}
.img3{left:470px;top:0;-webkit-transform:rotateZ(-10deg);}
.img4{left:720px;top:0;-webkit-transform:rotateZ(25deg);}
.img5{left:220px;top:200px;-webkit-transform:rotateZ(-2deg);}
.img6{left:830px;top:240px;-webkit-transform:rotateZ(-15deg);}
.img7{left:490px;top:190px;-webkit-transform:rotateZ(5deg);}
.img8{left:80px;top:430px;-webkit-transform:rotateZ(-5deg);}
.img9{left:290px;top:450px;-webkit-transform:rotateZ(5deg);}
.img10{left:510px;top:380px;-webkit-transform:rotateZ(-10deg);}
.img11{left:760px;top:500px;-webkit-transform:rotateZ(10deg);}
.img12{left:-100px;top:250px;-webkit-transform:rotateZ(-5deg);}
</style>
</head>
<body>
<div class="wall">
<img src="<a href="http://mp1.zhuqu.com/static/images/thb3/611/29/29a5296418b9f689968b22d3a9ebba07.jpg">http://mp1.zhuqu.com/static/images/thb3/611/29/29a5296418b9f689968b22d3a9ebba07.jpg</a>" alt="" class="img1"/>
<img src="<a href="http://h.hiphotos.baidu.com/image/pic/item/63d9f2d3572c11df1e33e52a612762d0f603c2dd.jpg">http://h.hiphotos.baidu.com/image/pic/item/63d9f2d3572c11df1e33e52a612762d0f603c2dd.jpg</a>" alt="" class="img2"/>
<img src="<a href="http://h.hiphotos.baidu.com/image/pic/item/4d086e061d950a7bdd523bb808d162d9f2d3c963.jpg">http://h.hiphotos.baidu.com/image/pic/item/4d086e061d950a7bdd523bb808d162d9f2d3c963.jpg</a>" alt="" class="img3"/>
<img src="<a href="http://f.hiphotos.baidu.com/image/pic/item/c9fcc3cec3fdfc031f73ebc4d63f8794a4c22646.jpg">http://f.hiphotos.baidu.com/image/pic/item/c9fcc3cec3fdfc031f73ebc4d63f8794a4c22646.jpg</a>" alt="" class="img4"/>
<img src="<a href="http://e.hiphotos.baidu.com/image/pic/item/902397dda144ad348d0a25fbd2a20cf431ad8511.jpg">http://e.hiphotos.baidu.com/image/pic/item/902397dda144ad348d0a25fbd2a20cf431ad8511.jpg</a>" alt="" class="img5"/>
<img src="<a href="http://a.hiphotos.baidu.com/image/pic/item/b03533fa828ba61ed8c6c2534334970a304e59a5.jpg">http://a.hiphotos.baidu.com/image/pic/item/b03533fa828ba61ed8c6c2534334970a304e59a5.jpg</a>" alt="" class="img6"/>
<img src="<a href="http://h.hiphotos.baidu.com/image/pic/item/d4628535e5dde711d794368aa5efce1b9d166103.jpg">http://h.hiphotos.baidu.com/image/pic/item/d4628535e5dde711d794368aa5efce1b9d166103.jpg</a>" alt="" class="img7"/>
<img src="<a href="http://h.hiphotos.baidu.com/image/pic/item/9213b07eca8065382b38ae6f95dda144ac3482ff.jpg">http://h.hiphotos.baidu.com/image/pic/item/9213b07eca8065382b38ae6f95dda144ac3482ff.jpg</a>" alt="" class="img8"/>
<img src="<a href="http://d.hiphotos.baidu.com/image/pic/item/bd315c6034a85edfd6938b5f4b540923dd5475aa.jpg">http://d.hiphotos.baidu.com/image/pic/item/bd315c6034a85edfd6938b5f4b540923dd5475aa.jpg</a>" alt="" class="img9"/>
<img src="<a href="http://e.hiphotos.baidu.com/image/pic/item/c995d143ad4bd113df57bd4e58afa40f4bfb0537.jpg">http://e.hiphotos.baidu.com/image/pic/item/c995d143ad4bd113df57bd4e58afa40f4bfb0537.jpg</a>" alt="" class="img10"/>
<img src="<a href="http://e.hiphotos.baidu.com/image/pic/item/7c1ed21b0ef41bd5c98ab2fd53da81cb38db3dd9.jpg">http://e.hiphotos.baidu.com/image/pic/item/7c1ed21b0ef41bd5c98ab2fd53da81cb38db3dd9.jpg</a>" alt="" class="img11"/>
<img src="<a href="http://c.hiphotos.baidu.com/image/pic/item/37d12f2eb9389b500dd0952e8735e5dde7116e9a.jpg">http://c.hiphotos.baidu.com/image/pic/item/37d12f2eb9389b500dd0952e8735e5dde7116e9a.jpg</a>" alt="" class="img12"/>
</div>
</body>
</html>
本例子只兼容了webkit內(nèi)核的瀏覽器,若要兼容其他內(nèi)核的瀏覽器需要添加其他前綴(-moz-、-o-等)。
另外,本例子中使用的 rotateZ 屬性的值的正負(fù)方向常使人發(fā)生混亂,在3D場(chǎng)景中,X軸正方向?yàn)樗较蛴遥琘軸正方向?yàn)榇怪毕蛳拢琙軸的正方向?yàn)榇怪庇谄聊幌蛲猓_定正方向之后只需要記住如下規(guī)則即可:從坐標(biāo)原點(diǎn)出發(fā),向著坐標(biāo)軸的正方向看去,逆時(shí)針旋轉(zhuǎn)時(shí)rotate(X/Y/Z)的值為正數(shù),順時(shí)針旋轉(zhuǎn)時(shí),rotate(X/Y/Z)值為負(fù)數(shù)。
效果非常棒,代碼也很簡單,主要是掌握好CSS3的幾個(gè)屬性,主要使用到的css3屬性有:transition、transform(scale、rotateZ)、box-shadow以及z-index。
“怎么用css3實(shí)現(xiàn)照片墻效果”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!
本文標(biāo)題:怎么用css3實(shí)現(xiàn)照片墻效果
分享路徑:http://chinadenli.net/article16/jpssdg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開發(fā)、做網(wǎng)站、云服務(wù)器、域名注冊(cè)、網(wǎng)站設(shè)計(jì)公司、網(wǎng)站策劃
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)