基於CSS3 3D百葉窗映像過渡特效

來源:互聯網
上載者:User

標籤:

你可能已經在網上看到過不少使用jQuery製作的百葉窗效果,我們可不可以使用純CSS來完成這項工作呢?答案是肯定的。我們不僅可以製作出這種百葉窗效果,還可以使它具有響應性。

線上預覽   源碼下載

要製作純CSS的百葉窗效果,HTML結構是個關鍵。在html結構中,需要使用多幅相同的圖片來組織一個“百葉窗”。我們的demo中製作10個百葉窗窗條,需要10個相同的<img>,將它們放置在一個<figure>標籤中。同時,我們還需要10幅其它圖片放置在百葉窗的反面。每一組圖片都設定不同的class,代碼如下:

<figure id="blinds">    <img src="autumn-face.jpg" alt class="first">    <img src="autumn-face.jpg" alt class="first">    …    <img src="autumn-face.jpg" alt class="first">    <img src="julia.jpg" alt class="second">    <img src="julia.jpg" alt class="second">    …    <img src="julia.jpg" alt class="second"></figure>   

這時候,所有的百葉窗切片將同時被旋轉。要製作百葉窗的“脈動”效果,可以為每個切片的transition設定一個延遲時間。

#blinds img:nth-child(1), #blinds img:nth-child(11) {    clip: rect(0px, 100px, 840px, 0px);    transform-origin: 50px 0px; }#blinds img:nth-child(2), #blinds img:nth-child(12) {    clip: rect(0px, 200px, 840px, 100px);    transform-origin: 150px 0px;    transition-delay: 100ms; }#blinds img:nth-child(3), #blinds img:nth-child(13) {    clip: rect(0px, 300px, 840px, 200px);    transform-origin: 250px 0px;    transition-delay: 200ms; }…#blinds img:nth-child(10n) {    clip: rect(0px, 1000px, 840px, 900px);    transform-origin: 950px 0px;    transition-delay: 900ms; }              

使用clip屬性的一個最大的好處是它天然具有響應式效果:如果圖片被縮小,所有的切片會相應的減少。查看demo,試著縮小你的瀏覽器,當瀏覽器的寬度小於500像素的時候,圖片百葉窗只有5個切片。

via:http://www.w2bc.com/Article/25379

基於CSS3 3D百葉窗映像過渡特效

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.