CSS3制作精致的照片墻特效

本文實(shí)例為大家分享利用CSS3動(dòng)畫制作照片墻的詳細(xì)步驟,供大家參考,具體內(nèi)容如下
第一種實(shí)現(xiàn)效果:
Html代碼如下:
- <body>
- <h2>照片墻制作</h2>
- <div class="container">
- <img class="img1" src="img/img (1).jpg" height="150" width="150" alt="">
- <img class="img2" src="img/img (2).jpg" height="160" width="200" alt="">
- <img class="img3" src="img/img (3).jpg" height="170" width="200" alt="">
- <img class="img4" src="img/img (4).jpg" height="240" width="200" alt="">
- <img class="img5" src="img/img (5).jpg" height="300" width="300" alt="">
- </div>
- </body>
CSS代碼如下:
- <style>
- * {margin:0; padding:0;}
- body { background-color: #eee; padding-top: 50px;}
- h2 { text-align: center;}
- .container { position: relative; width:1000px; height:700px; margin:0px auto; }
- img { position: absolute; top:50px; left:100px; cursor: pointer;
- padding:10px 10px 25px; background-color: #fff; border:1px solid #ddd;
- transition:0.5s; box-shadow: 3px 3px 3px #ccc;
- }
- .img1 { left:40px; top:20px; transform:rotate(30deg); z-index: 1;}
- .img2 { left:156px; top:156px; transform:rotate(-30deg); z-index: 1;}
- .img3 { left:381px; top:60px; transform:rotate(30deg); z-index: 1;}
- .img4 { left:458px; top:256px; transform:rotate(30deg); z-index: 1;}
- .img5 { left:684px; top:110px; transform:rotate(-40deg); z-index: 1;}
- img:hover { transform:rotate(0deg); transform:scale(1.5); box-shadow: 6px 6px 6px #656565; z-index: 2;}
- </style>
效果圖:
第二種實(shí)現(xiàn)效果:
第一部分:HTML
這里我們首先放十張圖片在頁面上面。(有什么靚照盡管上來哦?。?/p>
- <div class="content">
- <img class="pic1" src="img/1.jpg" />
- <img class="pic2" src="img/2.jpg" />
- <img class="pic3" src="img/3.jpg" />
- <img class="pic4" src="img/4.jpg" />
- <img class="pic5" src="img/5.jpg" />
- <img class="pic6" src="img/6.jpg" />
- <img class="pic7" src="img/7.jpg" />
- <img class="pic8" src="img/8.jpg" />
- <img class="pic9" src="img/9.jpg" />
- <img class="pic10" src="img/10.jpg" />
- </div>
第二部分:CSS3
這一部分就是我們這節(jié)的重點(diǎn)了,如上圖所示照片的位置各不相同,我們肯定會(huì)用到CSS3一下的知識(shí)點(diǎn):
CSS3的旋轉(zhuǎn) rotate
CSS3的縮放 scale
CSS3的陰影 box-shadow
沒錯(cuò)就是這些功能我們就可以做一個(gè)漂亮的照片墻了。來看看我們的代碼吧,這里只展示部分代碼了聰明的小伙伴肯定知道怎么做的!
- body{
- background: url(../img/bg1.jpg) no-repeat top center fixed;
- background-size: 100% auto;
- }
- .content{
- width: 900px;
- height: 1000px;
- overflow: hidden;
- margin: 100px auto;
- position: relative;
- }
- img{
- z-index: 1;
- width: 20%;
- height: auto;
- position: absolute;
- padding: 10px 10px 15px 10px;
- background: #ffffff;
- border: 1px solid #CCCCCC;
- /* 動(dòng)畫的時(shí)間 */
- -moz-transition: 0.5s;
- -webkit-transition: 0.5s;
- transition: 0.5s;
- }
- img:hover{
- z-index: 2;
- transform: scale(1.5);
- -moz-transform: scale(1.5) ;
- -webkit-transform: scale(1.5) ;
- box-shadow: -10px 10px 20px #000000;
- -moz-box-shadow: -10px 10px 20px #000000;
- -webkit-box-shadow: -10px 10px 20px #000000;
- }
- .pic1{
- left: 100px;
- top: 50px;
- -webkit-transform: rotate(20deg);
- -moz-transform: rotate(20deg);
- transform: rotate(20deg);
- }
- .pic2{
- left: 280px;
- top: 60px;
- -webkit-transform: rotate(-10deg);
- -moz-transform: rotate(-10deg);
- transform: rotate(-10deg);
- }
- /* 下面的代碼大同小異就不依依展示了 */
就是這么簡單的代碼就可以實(shí)現(xiàn)上圖所示的效果了。小伙伴們有興趣的自己動(dòng)手嘗試一下把自己的靚照放上去看看。
PS: CSS3還可以寫出更多的精彩絢麗效果,小伙伴有興趣可以深入的研究一下!
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
- 這篇文章主要介紹了純css實(shí)現(xiàn)照片墻3D效果的示例代碼,可以實(shí)現(xiàn)鼠標(biāo)經(jīng)過圖片實(shí)現(xiàn)改變,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-11-13
- 下面小編就為大家?guī)硪黄狢SS3制作漂亮的照片墻的實(shí)現(xiàn)代碼。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-08
CSS3實(shí)現(xiàn)漂亮的照片墻效果的簡單實(shí)例(推薦)
下面小編就為大家?guī)硪黄狢SS3實(shí)現(xiàn)漂亮的照片墻效果的簡單實(shí)例(推薦)。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2016-06-03CSS3實(shí)現(xiàn)鼠標(biāo)懸停照片墻放大特效源碼
CSS3實(shí)現(xiàn)鼠標(biāo)懸停照片墻放大特效源碼是一款圖片默認(rèn)3行4列排列,鼠標(biāo)經(jīng)過突出方法顯示圖片。大家對此效果非常心動(dòng)不妨前來下載使用2016-04-13- 這篇文章主要介紹了純css3實(shí)現(xiàn)照片墻效果,鼠標(biāo)懸浮時(shí)旋轉(zhuǎn)放大并擺正,主要使用到的css3屬性有:transition、transform(scale、rotateZ)、box-shadow以及z-index,推薦給2014-12-26
- 本文給大家推薦的是使用CSS3簡單實(shí)現(xiàn)照片墻效果的代碼,非常簡單,也很實(shí)用,需要的朋友可以參考下2014-12-12
- 這是一款基于CSS3實(shí)現(xiàn)的懸掛照片墻效果源碼,是一款基于CSS3 transform 屬性制作懸掛的照片墻效果代碼2014-09-03
jquery+css3實(shí)現(xiàn)非常大氣的瀑布流照片墻特效
一款效果非??岬恼掌瑝ψ髌?,展示相片的效果非常大氣2014-03-05- 這篇文章主要介紹了利用css制作3D照片墻效果,代碼簡單易懂,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-10-29