linear-gradient 是CSS3中一個重要的屬性,初看覺得很簡單,但是別看它簡單,它能實現(xiàn)很多復雜的圖形。

代碼還是比較簡單的: linear-gradient(65deg,#2b7ce7,#2b7ce7 50%,transparent 0,transparent),linear-gradient(115deg,#2b7ce7,#2b7ce7 50%,transparent 0,transparent)
但是理解起來還是需要一定基礎的。
線性漸變 linear-gradient
基本用法
background-image: linear-gradient(red, yellow, blue, green); background-image: linear-gradient(rgba(255, 0, 0, .2), yellow, blue, green);
控制顏色漸變的方向(right, left, top, bottom)
/* 控制顏色漸變的方向 to right -- 從左向右 to top -- 從下到上 to left -- 從右到左 to bottom --- 從上到下(默認值)*/background-image: linear-gradient(to right, red, yellow, blue, green);background-image: linear-gradient(to top, red, yellow, blue, green);background-image: linear-gradient(to left, red, yellow, blue, green);background-image: linear-gradient(to bottom, red, yellow, blue, green);
控制顏色漸變的方向(deg)
/*0deg = to top -- 從下到上*/background-image: linear-gradient(0deg, red, yellow, blue, green);/*基于0度順時針旋轉(zhuǎn)45deg*/background-image: linear-gradient(45deg, red, yellow, blue, green);/*基于0度逆時針旋轉(zhuǎn)45deg*/background-image: linear-gradient(-45deg, red, yellow, blue, green);
控制顏色漸變的方向(to)
/*設置過渡顏色的起始位置*//*從過渡起始位置50px開始讓紅色和黃色之間產(chǎn)生顏色漸變效果*/background-image: linear-gradient(to right, red 50px, yellow, blue, green);background-image: linear-gradient(to right, red 50px, yellow 50px, blue, green);background-image: linear-gradient(to right, red 50px, yellow 50px, yellow 100px, blue, green);
重復線性漸變:repeating-linear-gradient
background-image: linear-gradient(to right, red 0, red 50px, yellow 50px, yellow 100px, red 100px, red 150px, yellow 150px, yellow 200px);/**與上面重復寫漸變有相同的效果*/background-image: repeating-linear-gradient( to right , red 0 , red 50px , yellow 50px , yellow 100px);
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持武林網(wǎng)。
新聞熱點
疑難解答