【CSS3】使用CSS3線性漸層實現圖片閃光划過效果(轉)

來源:互聯網
上載者:User

標籤:blog   http   io   ar   os   使用   for   sp   div   

原文:http://www.nowamagic.net/librarys/veda/detail/2600

資料參考:

http://www.cnblogs.com/lhb25/archive/2013/01/30/css3-linear-gradient.html  CSS3 經典教程系列:CSS3 線性漸層(linear-gradient)

 

HTML

<p class="overimg"><a><img src="http://www.nowamagic.net/librarys/images/201402/2014_02_15_01.jpg"></a><i class="light"></i></p>

 

css

.overimg{position: relative;display: block;/* overflow: hidden; */box-shadow: 0 0 10px #FFF;}.light{cursor:pointer;position: absolute;left: -180px;top: 0;width: 180px;height: 90px;background-image: -moz-linear-gradient(0deg,rgba(255,255,255,0),rgba(255,255,255,0.5),rgba(255,255,255,0));background-image: -webkit-linear-gradient(0deg,rgba(255,255,255,0),rgba(255,255,255,0.5),rgba(255,255,255,0));transform: skewx(-25deg);-o-transform: skewx(-25deg);-moz-transform: skewx(-25deg);-webkit-transform: skewx(-25deg); }.overimg:hover .light{left:180px;-moz-transition:0.5s;-o-transition:0.5s;-webkit-transition:0.5s;transition:0.5s;}

  

大體思想是,設計一個透明層i,skewx在X軸上做了負25度的變形,背景顏色用的是CSS3的線性漸層linear-gradient,然後hover的時候,設定0.5s的動畫時間。

同時在 i 層使用 cursor:pointer,如果不設定這個的話,需要等透明層動畫之後才能看得到 pointer 指標。

開啟 F12 調試來看會更加清楚。

【CSS3】使用CSS3線性漸層實現圖片閃光划過效果(轉)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.