CSS的力量:用一個DIV畫圖

來源:互聯網
上載者:User

標籤:http   ar   for   2014   div   sp   on   line   c   

這些圖片都是用一個DIV繪製出來的,其實原理並不複雜。

  這些圖片都是由CSS繪製出來的,通過background-image疊加實現,

  如蘑菇頭的實現,通過 radial-gradient 放射狀漸層 , linear-gradient 線性漸層相互疊加實現,如:

123456789101112 div {  width: 170px;  height: 140px;  background-image:         radial-gradient(circle at 50% 120%, rgba(0,0,0,0.7) 23%, rgba(0,0,0,0) 48%),        linear-gradient(30deg, rgba(0,0,0,0.4) 10%, rgba(0,0,0,0) 20%),        radial-gradient(circle at 50% 33%, #f8f6f7 32%, rgba(255,255,255,0) 32%),        radial-gradient(circle at -13% 55%, #f8f6f7 20%, rgba(255,255,255,0) 20%),        radial-gradient(circle at 113% 55%, #f8f6f7 20%, rgba(255,255,255,0) 20%),        linear-gradient(to bottom, #ef0015 20%, #b2000c 100%);        border-radius: 140px 140px 80px 80px;}

  線上示範:在此

  同時有前後遮擋關係的通過:before和:after虛擬元素的background-image來實現。

  PS: 此種手法對並不完全支援舊版IE

  原文地址: 點此

CSS的力量:用一個DIV畫圖

聯繫我們

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