css3實現iPhone滑動解鎖

來源:互聯網
上載者:User

標籤:style   blog   http   io   ar   color   os   使用   sp   

該效果的主要實現思路是給文字添加漸層的背景,然後對背景進行裁剪,按文字裁剪(目前只有webkit核心瀏覽器支援該屬性),最後給背景添加動畫,即改變背景的位置,背景動畫效果如下(GIF錄製時有卡頓,代碼實現時不卡):

最終效果:

全部代碼如下:

<!DOCTYPE html><html><head>    <style>        p{            width:50%;            margin:0 auto;            line-height:50px;             font-size:50px;             text-align:center;                        -webkit-background-clip: text;    /*按文字裁剪*/                    -webkit-text-fill-color: transparent;    /*文字的顏色使用背景色*/                            background-color:#19385c;    /*設定一個背景色*/                    background-image: -webkit-linear-gradient(-45deg, rgba(0, 0, 0, 0.6) 30%, #aff0ff 50%, rgba(0, 0, 0, 0.6) 70%);        /*設定漸層的背景,按對角線漸層*/                        background-blend-mode: hard-light;    /*設定背景為混合模式下的強光模式*/            background-size: 200%;                        -webkit-animation: shine 4s infinite;    /*給背景添加動畫改變位置*/        }        @-webkit-keyframes shine {          from {background-position: 100%;}          to {background-position: 0;}        }    </style></head><body><p>&gt;&nbsp;Slide To Unlock</p></body></html>

需要說明的是由於按文字裁剪目前只有 webkit 核心可用,所以該效果目前不相容其他核心瀏覽器。

 

css3實現iPhone滑動解鎖

聯繫我們

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