css3漸層詳解

來源:互聯網
上載者:User

標籤:style   blog   http   color   os   使用   strong   for   ar   

今天總結漸層的問題,漸層分為線性漸層、放射狀漸層。呼呼,廢話少說,

線性漸層:background:linear-gradient(設定漸層形式,第一個顏色起點,中間顏色點 中間顏色的位置,結束點顏色);

Linear:漸層的類型(線性漸層);

漸層的形式:選擇性參數 有兩種方式-1、設定旋轉角度,0度代表水平從左至右,90度就是從上到下啦,從0度開始逆時針變換。

2、使用關鍵字,left代表從左至右,top代表從上到下,同理right就是從右至左,lefttop-從坐上到右下,同理leftbottom,righttop,rightbottom。

中間顏色與中間顏色位置為選擇性參數。

不過要考慮瀏覽器的相容,咱們這樣寫:

-webkit-gradient(linear,0  0,0  100%,from(起始顏色,to(結束顏色));  /*for Safari4+,Chrome 2+*/

-webkit-linear-gradient(起始顏色, 結束顏色);  /*for Safari 5.1+,Chrome 10+*/

-moz-linear-gradient(起始顏色, 結束顏色);  /*for firefox*/

-o-linear-gradient(起始顏色, 結束顏色);  /*Opera*/

linear-gradient(起始顏色, 結束顏色);  /*標準屬性*/

對於IE來說是個麻煩事,老辦法

Filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=’ 起始顏色’,endColorstr=” 結束顏色”);  /*IE6,IE 7*/

-ms-linear-gradient(起始顏色, 結束顏色);  /*IE8*/

<div class="content1"></div>

.content1{width:500px;height:300px;border-radius:10%;background:#ade691;
background:-webkit-linear-gradient(left,#88cfc3,#329e8c 30%,#096e5d);background:-moz-linear-gradient(left,#88cfc3,#329e8c 30%,#096e5d);background:filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=‘#88cfc3‘, endColorstr=‘#096e5d‘); /* IE6,IE7 */-ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=‘#88cfc3‘, endColorstr=‘#096e5d‘)";background:linear-gradient(lleft,#88cfc3,#329e8c 30%,#096e5d;float:left;}
.tit1{font-size:3em;font-weight: bold;color:#f00;}

重複性線性漸層:repeating-linear-gradient屬性來代替線性漸層linear-gradient;

<div class="content2"></div>

.content2{width:500px;height:200px;
background-image: -webkit-repeating-linear-gradient(red,green 40px, orange 80px);
background-image: repeating-linear-gradient(red,green 40px, orange 80px);}

 

 

放射狀漸層:radial-gradient(設定漸層的中心,漸層形狀 漸層大小,起始顏色值,中間顏色值 中間顏色位置,終點顏色)

漸層中心,選擇性參數,如30px 20px指距離左側30px距離上側20px,可以是像素,可以是百分比,也可以是關鍵字,預設為中心位置。

漸層形狀,選擇性參數,可以取值circle或eclipse【預設】

漸層大小,可迴圈參數,可以取值

closest-side:

指定放射狀漸層的半徑長度為從圓心到離圓心最近的邊

closest-corner:

指定放射狀漸層的半徑長度為從圓心到離圓心最近的角

farthest-side:

指定放射狀漸層的半徑長度為從圓心到離圓心最遠的邊

farthest-corner:

指定放射狀漸層的半徑長度為從圓心到離圓心最遠的角

contain:

包含,指定放射狀漸層的半徑長度為從圓心到離圓心最近的點。類同於closest-side

cover:

覆蓋,指定放射狀漸層的半徑長度為從圓心到離圓心最遠的點。類同於farthest-corner

 circle farthest-corner圓形漸層,ellipse farthest-corner橢圓漸層

<div class="content3"></div>

.content3{width:500px;height:200px;
background-image: -webkit-radial-gradient(circle,hsla(120,70%,60%,.9),hsla(360,60%,60%,.9));
background-image: radial-gradient(circle,hsla(120,70%,60%,.9),hsla(360,60%,60%,.9));margin-top:20px;}

對於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.