当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


CSS repeating-linear-gradient()用法及代码示例


repeating-linear-gradient()函数是CSS中的内置函数,用于重复线性渐变。

用法:

background-image:repeating-linear-gradient( angle | to side-or-corner, color-stop1,
color-stop2, ...); 

参数:该函数接受许多下面列出的参数:


  • angle:此参数用于保存渐变的方向角。其值介于0到360度之间。默认情况下,其值为180度。
  • side-or-corner:此参数用于定义渐变线的starting-point的位置。它由两个关键字组成:第一个关键字指示水平边(左侧或右侧),第二个关键字指示垂直边(顶部或底部)。顺序无关紧要,每个关键字都是可选的。
  • color-stop1,color-stop2…:此参数用于保留颜色值及其后的可选停止位置。

以下示例说明了CSS中的repeating-linear-gradient()函数:

范例1:

<!DOCTYPE html>  
<html>  
    <head>  
        <title>repeating-linear-gradient() Function</title>  
        <style>  
            #main {  
                height:200px;  
                background-color:white;  
                background-image:repeating-linear-gradient(#090,  
                                        #fff 10%, #2a4f32 20%);  
            }  
            .gfg {  
                text-align:center;  
                font-size:40px;  
                font-weight:bold;  
                padding-top:80px;  
            }  
            .geeks {  
                font-size:17px;  
                text-align:center;  
            }  
        </style>  
    </head>  
    <body>  
        <div id="main">  
            <div class = "gfg">GeeksforGeeks</div>  
            <div class = "geeks">A computer science portal for geeks</div>  
        </div>  
    </body>  
</html>                    

输出:
repeating linear gradient

范例2:

<!DOCTYPE html>  
<html>  
    <head>  
        <title>repeating-linear-gradient() Function</title>  
        <style>  
            #main {  
                height:200px;  
                background-color:white;  
                background-image:repeating-linear-gradient(45deg,  
                blue, green 7%, white 10%);  
            }  
            .gfg {  
                text-align:center;  
                font-size:40px;  
                font-weight:bold;  
                padding-top:80px;  
            }  
            .geeks {  
                font-size:17px;  
                text-align:center;  
            }  
        </style>  
    </head>  
    <body>  
        <div id="main">  
            <div class = "gfg">GeeksforGeeks</div>  
            <div class = "geeks">A computer science portal for geeks</div>  
        </div>  
    </body>  
</html>                    

输出:



相关用法


注:本文由纯净天空筛选整理自Mahadev99大神的英文原创作品 CSS | repeating-linear-gradient() Function。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。