CSS3常见的几种色调渐变色方式总结

日期:2021-03-02 类型:科技新闻 

关键词:抠图软件电脑版,在线图片加水印,在线 抠图,在线画图网站,淘宝做图片用什么软件好

1、线形渐变色:linear-gradient

英语的语法:

        <linear-gradient> = linear-gradient([ [ <angle> | to <side-or-corner] ,]? <color-start>[, <color-end>]+)
        <side-or-corner> = [left | right] || [top | bottom]
        <color-start|end> = <color>[ <length>|<percentage>]?

下述值用来表明渐变色的方位,可使用角度或重要字来设定:

    <angle>:用角度值特定渐变色的方位(或角度)。

        to left:设定渐变色为从右到左。非常于: 270deg

        to right:设定渐变色从左到右。非常于: 90deg

        to top:设定渐变色从下到上。非常于: 0deg

        to bottom:设定渐变色从上到下。非常于: 180deg。这是默认设置值,等同于于留空不写。

    <color-start|end> 用于特定渐变色的起始色调:

       <color>:特定色调。

       <length>:用长度值特定起始色部位。不容许负值

       <percentage>:用百分比特定起始色部位。

示例:

div {  
    width: 200px;  
    height: 100px;  
    margin: 10px 5px;  
    border: 1px solid #ddd000;  
}  
#LinearStartToEnd {  
  float:left;  
  background: linear-gradient(#ff0000, #00ff00);  
}  
#LinearPercentage {  
  float:left;  
  background: linear-gradient(#0000ff, #ff0000 52%, #00ff00);  
}  
#LinearAnglePercentage {  
  float:left;  
  background: linear-gradient(90deg, #ff0000 20%, #00ff00 50%, #000000 80%);  
}  
#LinearAngle {  
  float:left;  
  background: linear-gradient(30deg, #ffff00 30%, #ff0000, #00ff00);  
}  
#LinearTopRight {  
  float:left;  
  background: linear-gradient(to right top, #00ff00, #ff0000 50%, #0000ff);  
}  

2、轴向渐变色:radial-gradient

英语的语法:

     <position> = [ <length>① | <percentage>① | left | center① | right ]? [ <length>② | <percentage>② | top | center② | bottom ]?
     <shape> = circle | ellipse
     <size> = <extent-keyword>|[<circle-size>||<ellipse-size>]
     <extent-keyword> = closest-side | closest-corner | farthest-side | farthest-corner
     <circle-size> = <length>
     <ellipse-size> = [ <length>| <percentage> ]{2}
     <shape-size> = <length>| <percentage>
     <radial-gradient> = radial-gradient([ [ <shape>|| <size> ] [ at <position> ]? , | at <position> , ]?<color-start>[[ , <color-end>]]+)

       <position> 明确圆心的部位。假如出示2个主要参数,第1个表明横座标,第2个表明纵座标;假如只出示1个,第2值默认设置为50%,即center

         <length>①:用长度值特定轴向渐变色圆心的横座标值。能够为负值。

         <percentage>①:用百分比特定轴向渐变色圆心的横座标值。能够为负值。

         <length>②:用长度值特定轴向渐变色圆心的纵座标值。能够为负值。

         <percentage>②:用百分比特定轴向渐变色圆心的纵座标值。能够为负值。

              center①:设定正中间为轴向渐变色圆心的横座标值。

              center②:设定正中间为轴向渐变色圆心的纵座标值。

              left:设定左侧为轴向渐变色圆心的横座标值。

              right:设定右侧为轴向渐变色圆心的横座标值。

              top:设定顶部为轴向渐变色圆心的纵座标值。

              bottom:设定底部为轴向渐变色圆心的纵座标值。

       <shape> 明确圆的种类

              circle:特定圆形的轴向渐变色

              ellipse:特定椭圆型的轴向渐变色。

       <extent-keyword> circle | ellipse 都接纳该值做为 size。

              closest-side:特定轴向渐变色的半径长度为从圆心到离圆心近期的边。

              closest-corner:特定轴向渐变色的半径长度为从圆心到离圆心近期的角。

              farthest-side:特定轴向渐变色的半径长度为从圆心到离圆心最远的边。

              farthest-corner:特定轴向渐变色的半径长度为从圆心到离圆心最远的角。

       <circle-size> circle 接纳该值做为 size。

              <length>:用长度值特定正圆轴向渐变色的半径长度。不容许负值。

       <ellipse-size> ellipse 接纳该值做为 size。

             <length>:用长度值特定椭圆轴向渐变色的横向或纵向半径长度。不容许负值。

             <percentage>:用百分比特定椭圆轴向渐变色的横向或纵向半径长度。不容许负值。

示例:

#RadialCenterCircle {  
  float:left;  
    background: radial-gradient(circle at center, #ff0000, #ffff00, #00ffff);  
}  
#RadialClosestSide {  
  float:left;  
    background: radial-gradient(circle closest-side, #ff0000, #00ff00, #ffff00);  
}  
#RadialFarthestSide {  
  float:left;  
    background: radial-gradient(farthest-side, #ff0000 20%, #ffff00 60%, #00ff00 80%);  
}  
#RadialRightTop {  
  float:left;  
    background: radial-gradient(at right top, #ff0000, #ffff00, #00ff00);  
}  
#RadialRadiusCenter {  
  float:left;  
    background: radial-gradient(farthest-side at top right, #ff0000, #ffff00, #01fefe);  
}  
#RadialGroup {  
  float:left;  
    background:  
        radial-gradient(farthest-side at top right, #ff0000, #ffff00, #009f00, transparent),  
        radial-gradient(60px at top left, #ff0000, #ffff00, #00ff0e);  
}  

3、反复的线形渐变色:repeating-linear-gradient

英语的语法和主要参数相近线形渐变色,这里不在赘述。详细信息请参照CSS手册。

示例:

 

#RepeatingLinearPercentage{  
  float:left;  
    background: repeating-linear-gradient(#ff0000, #00ff00 10%, #000000 15%);  
}  
#RepeatingLinearRight {  
  float:left;  
    background: repeating-linear-gradient(to right, #ff0000, #00ff00 10%, #000000 15%);  
}  
#RepeatingLinearAngle {  
  float:left;  
    background: repeating-linear-gradient(45deg, #ff0000, #00ff00 10%, #0000ff 15%);  
}  
#RepeatingLinearBottomLeft {  
  float:left;  
    background: repeating-linear-gradient(to bottom left, #00ffff, #ff0000 10%, #00ff00 15%);  
}  

4、反复的轴向渐变色:repeating-radial-gradient

英语的语法和主要参数相近轴向渐变色,这里不在赘述。详细信息请参照CSS手册。

示例:

#RepeatingRadialCircle {  
  float:left;  
    background: repeating-radial-gradient(circle, #ff0000 0, #00ff00 10%, #0000ff 15%);  
}  
#RepeatingRadialTopLeft {  
  float:left;  
    background: repeating-radial-gradient(at top left, #ff0000, #00ff00 10%, #0de0f0 15%, #ffff00 20%, #000000 25%);  
}  
#RepeatingRadialClosestCorner {  
  float:left;  
    background: repeating-radial-gradient(circle closest-corner at 20px 50px, #00ff00, #ff0000 10%, #00ffff 20%, #ffff00 30%, #ff00ff 40%);  
}  

详细的事例:

<!DOCTYPE html>  
<html>  
<head>  
<meta charset="utf⑻" />  
<title>ImageCSS3</title>  
<style>  
div {  
    width: 200px;  
    height: 100px;  
    margin: 10px 5px;  
    border: 1px solid #ddd000;  
}  
#LinearStartToEnd {  
  float:left;  
  background: linear-gradient(#ff0000, #00ff00);  
}  
#LinearPercentage {  
  float:left;  
  background: linear-gradient(#0000ff, #ff0000 52%, #00ff00);  
}  
#LinearAnglePercentage {  
  float:left;  
  background: linear-gradient(90deg, #ff0000 20%, #00ff00 50%, #000000 80%);  
}  
#LinearAngle {  
  float:left;  
  background: linear-gradient(30deg, #ffff00 30%, #ff0000, #00ff00);  
}  
#LinearTopRight {  
  float:left;  
  background: linear-gradient(to right top, #00ff00, #ff0000 50%, #0000ff);  
}  
  
#RadialCenterCircle {  
  float:left;  
    background: radial-gradient(circle at center, #ff0000, #ffff00, #00ffff);  
}  
#RadialClosestSide {  
  float:left;  
    background: radial-gradient(circle closest-side, #ff0000, #00ff00, #ffff00);  
}  
#RadialFarthestSide {  
  float:left;  
    background: radial-gradient(farthest-side, #ff0000 20%, #ffff00 60%, #00ff00 80%);  
}  
#RadialRightTop {  
  float:left;  
    background: radial-gradient(at right top, #ff0000, #ffff00, #00ff00);  
}  
#RadialRadiusCenter {  
  float:left;  
    background: radial-gradient(farthest-side at top right, #ff0000, #ffff00, #01fefe);  
}  
#RadialGroup {  
  float:left;  
    background:  
                radial-gradient(farthest-side at top right, #ff0000, #ffff00, #009f00, transparent),  
                radial-gradient(60px at top left, #ff0000, #ffff00, #00ff0e);  
}  
  
#RepeatingLinearPercentage{  
  float:left;  
    background: repeating-linear-gradient(#ff0000, #00ff00 10%, #000000 15%);  
}  
#RepeatingLinearRight {  
  float:left;  
    background: repeating-linear-gradient(to right, #ff0000, #00ff00 10%, #000000 15%);  
}  
#RepeatingLinearAngle {  
  float:left;  
    background: repeating-linear-gradient(45deg, #ff0000, #00ff00 10%, #0000ff 15%);  
}  
#RepeatingLinearBottomLeft {  
  float:left;  
    background: repeating-linear-gradient(to bottom left, #00ffff, #ff0000 10%, #00ff00 15%);  
}  
  
#RepeatingRadialCircle {  
  float:left;  
    background: repeating-radial-gradient(circle, #ff0000 0, #00ff00 10%, #0000ff 15%);  
}  
#RepeatingRadialTopLeft {  
  float:left;  
    background: repeating-radial-gradient(at top left, #ff0000, #00ff00 10%, #0de0f0 15%, #ffff00 20%, #000000 25%);  
}  
#RepeatingRadialClosestCorner {  
  float:left;  
    background: repeating-radial-gradient(circle closest-corner at 20px 50px, #00ff00, #ff0000 10%, #00ffff 20%, #ffff00 30%, #ff00ff 40%);  
}  
  
</style>  
</head>  
<body>  
<!-- 特定线形渐变色起始色 -->  
<div id="LinearStartToEnd"></div>  
<!-- 特定线形渐变色起始色部位 -->  
<div id="LinearPercentage"></div>  
<!-- 特定线形渐变色色调渐变色方位和起始色部位 -->  
<div id="LinearAnglePercentage"></div>  
<!-- 特定线形渐变色色调渐变色方位 -->  
<div id="LinearAngle"></div>  
<!-- 设定渐变色从右上到左下 -->  
<div id="LinearTopRight"></div>  
  
<!-- 波动Div换行,此处特定Div宽高和界限,是以便遮盖前面界定的Div统1CSS款式,  
 能够尝试去掉特定的Div宽高和界限,看看实际效果 -->  
<div style="width:0; height:0; border:none; clear:both"></div>  
<!-- 以管理中心点为圆心的圆形轴向渐变色 -->  
<div id="RadialCenterCircle"></div>  
<!-- 轴向渐变色半径长度:圆心到离圆心近期边的长度 -->  
<div id="RadialClosestSide"></div>  
<!-- 轴向渐变色半径长度:圆心到离圆心最远边的长度 -->  
<div id="RadialFarthestSide"></div>  
<!-- 左侧为轴向渐变色圆心的横座标值,顶边为轴向渐变色圆心的纵座标值 -->  
<div id="RadialRightTop"></div>  
<!-- 另外特定轴向渐变色的圆心和半径 -->  
<div id="RadialRadiusCenter"></div>  
<!-- 轴向渐变色组成 -->  
<div id="RadialGroup"></div>  
  
<div style="width:0; height:0; border:none; clear:both"></div>  
<!-- 特定色调起始色部位的反复线形渐变色 -->  
<div id="RepeatingLinearPercentage"></div>  
<!-- 从左到右渐变色的反复线形渐变色 -->  
<div id="RepeatingLinearRight"></div>  
<!-- 渐变色角度为45度的反复线形渐变色 -->  
<div id="RepeatingLinearAngle"></div>  
<!-- 从左下到右上的反复线形渐变色 -->  
<div id="RepeatingLinearBottomLeft"></div>  
  
<div style="width:0; height:0; border:none; clear:both"></div>  
<!-- 圆形反复轴向渐变色 -->  
<div id="RepeatingRadialCircle"></div>  
<!-- 渐变色方位为左上到右下的反复轴向渐变色 -->  
<div id="RepeatingRadialTopLeft"></div>  
<!-- 反复轴向渐变色:渐变色半径长度为从圆心到离圆心近期的角的间距 -->  
<div id="RepeatingRadialClosestCorner"></div>  
  
</body>  
</html>  

总结

以上便是这篇文章内容文章内容的所有內容,本文梳理了如今常见的几种Css3完成渐变色色调的方式,期待对大伙儿的学习培训或工作中能有一定的协助,假如有疑惑大伙儿能够留言沟通交流。