非常教程

CSS参考手册

图像值 | Image Values

重复线性渐变 | repeating-linear-gradient

repeating-linear-gradient()函数创建一个由重复线性渐变组成的 <image>。它类似于linear-gradient() 并采取相同的参数, 但它重复的颜色停止无限的所有方向, 以覆盖其整个容器。函数的结果是 <gradient> 数据类型的一个对象, 它是一种特殊的 <image>

/* A repeating gradient tilted 45 degrees,
   starting blue and finishing red */
repeating-linear-gradient(45deg, blue, red);

/* A repeating gradient going from the bottom right to the top left,
   starting blue and finishing red */
repeating-linear-gradient(to left top, blue, red);

/* A repeating gradient going from the bottom to top,
   starting blue, turning green after 40%,
   and finishing red */
repeating-linear-gradient(0deg, blue, green 40%, red);

每次重复, 颜色停止的位置由基本线性渐变的长度的倍数 (最后颜色中止和第一个之间的距离) 转移。因此, 每个结束色停止的位置与起始色停止重合;如果颜色值不同, 这将导致急剧的视觉转换。

与任何梯度一样,重复的线性梯度具有没有内在维度也就是说,它没有自然的或优先的大小,也没有优先的比率。它的具体大小将与它所应用的元素的大小相匹配。

使用说明:由于<gradient>s属于<image>数据类型,因此只能在可以使用<image>s的地方使用。出于这个原因,repeating-linear-gradient()将不能在background-color其他使用<color>数据类型的属性上工作。

句法

价值

<side-or-corner>渐变线起点的位置。如果指定,则由单词to和最多两个关键字组成:一个表示水平面(leftright),另一个表示垂直面(topbottom)。侧面关键字的顺序无关紧要。如果未指定,则默认为tobottom.The值to topto bottomto left,和to right等同于角度0deg180deg270deg,和90deg分别。其他值被翻译成一个角度。<angle>梯度线的方向角度。从头开始,to top顺时针旋转。<color-stop>一个颜色停止的<color>值,后跟一个可选的停止位置(a <percentage><length>沿着渐变轴)。

注意:在CSS渐变中渲染颜色停止符合与SVG渐变中的颜色停止相同的规则。

形式语法

repeating-linear-gradient(  [ <angle> | to <side-or-corner> ,]? <color-stop> [, <color-stop>]+ )
                            \---------------------------------/ \----------------------------/
                              Definition of the gradient line         List of color stops  

where <side-or-corner> = [left | right] || [top | bottom]
   and <color-stop>     = <color> [ <percentage> | <length> ]?

实例

#grad1 {
  background-image: repeating-linear-gradient(180deg,
      rgb(26,198,204),
      rgb(26,198,204) 7%,
      rgb(100,100,100) 10%);
}

#grad2 {
  background-image: repeating-linear-gradient(-45deg,
      transparent,
      transparent 25px,
      rgba(255,255,255,1) 25px,
      rgba(255,255,255,1) 50px);
}
<ol>
  <li>Repeating horizontal bars
    <div id="grad1"></div>
  </li>
  <li>Zebra stripes   
    <div id="grad2"></div>
  </li>     
</ol>
div {
  display: block;
  width: 50%;
  height: 80px;
  border-color: #000000;
  padding: 10px;
}

#grad1 {
  background-image: -moz-repeating-linear-gradient(180deg,rgb(26,198,204),rgb(26,198,204) 7%, rgb(100,100,100) 10%);
  background-image: -webkit-repeating-linear-gradient(180deg,rgb(26,198,204),rgb(26,198,204) 7%, rgb(100,100,100) 10%);
  background-image: -o-repeating-linear-gradient(180deg,rgb(26,198,204),rgb(26,198,204) 7%, rgb(100,100,100) 10%);
  background-image: repeating-linear-gradient(180deg,rgb(26,198,204),rgb(26,198,204) 7%, rgb(100,100,100) 10%);
}

#grad2 {
  background-color: black;
  background-image: -moz-repeating-linear-gradient(-45deg, transparent, transparent 25px, rgba(255,255,255,1) 25px, rgba(255,255,255,1) 50px);
  background-image: -webkit-repeating-linear-gradient(-45deg, transparent, transparent 25px, rgba(255,255,255,1) 25px, rgba(255,255,255,1) 50px);
  background-image: -o-repeating-linear-gradient(-45deg, transparent, transparent 25px, rgba(255,255,255,1) 25px, rgba(255,255,255,1) 50px);
  background-image: -ms-repeating-linear-gradient(-45deg, transparent, transparent 25px, rgba(255,255,255,1) 25px, rgba(255,255,255,1) 50px);
  background-image: repeating-linear-gradient(-45deg, transparent, transparent 25px, rgba(255,255,255,1) 25px, rgba(255,255,255,1) 50px);
}
<ol>
  <li>repeating gradient
    <div id="grad1"></div>
  </li>
  <li>Zebra pattern   
    <div id="grad2"></div>
  </li>     
</ol>

规格

Specification

Status

Comment

CSS Image Values and Replaced Content Module Level 3The definition of 'repeating-linear-gradient()' in that specification.

Candidate Recommendation

Initial definition.

浏览器兼容性

Feature

Firefox (Gecko)

Chrome

Internet Explorer

Opera

Safari

Basic support (on background and background-image)

3.6 (1.9.2)-moz3 16 (16)5

10.0 (534.16)-webkit 2

10.0 1

11.10-o 3

5.1-webkit2

On border-radius

29 (29)

(Yes)

(Yes)

(Yes)

(Yes)

On any other property that accept <image>

No support

(Yes)

(Yes)

(Yes)

(Yes)

Legacy webkit syntax

No support

3-webkit 2

No support

No support

4.0-webkit2

Legacy from syntax (without to)

3.6 (1.9.2)-moz4 Removed in 16 (16)7

10.0 (534.16)-webkit 2

10.0

11.10-o4

5.1-webkit2

to syntax

10 (10)-moz4 16 (16)

26.0

10.0

11.60-o4 Presto 2.12 will remove the prefix.

No support

Interpolation hints/gradient midpoints (a percent without a color)

36 (36)

40

?

27

(Yes)6

Unitless 0 for <angle>

46 (46)-webkit8 No support9

(Yes)

Edge 12

(Yes)

(Yes)

Feature

Firefox (Gecko)

Chrome

Internet Explorer

Opera (Presto)

Safari

Basic support

1.0 (1.9.2)-moz3 16.0 (16)5

16-webkit 26

10

(Yes)

(Yes)6

CSS

层叠样式表( Cascading Style Sheets )是一种用来表现 HTML 或 XML 等文件样式的计算机语言。CSS 不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。

CSS目录

1.动画和转换 | Animations & Transitions
2.背景和边框 | Backgrounds & Borders
3.基本框模型 | Basic Box Model
4.基本用户界面 | Basic User Interface
5.框对齐 | Box Alignment
6. 级联和继承 | Cascading & Inheritance
7.颜色 | Color
8. 合成与混合 | Compositing & Blending
9.条件和规则 | Conditional Rules
10.计数器样式 | Counter Styles
11.设备适配 | Device Adaptation
12.扩展 | Extensions
13.滤镜效果 | Filter Effects
14.灵活的框布局 | Flexible Box Layout
15.字体 | Fonts
16.片段模块 | Fragmentation
17.全屏 API | Fullscreen API
18. 生成内容 | Generated Content
19.网格布局 | Grid Layout
20.图像值 | Image Values
21.初始线格局 | Inline Layout
22.列表和计数器 | Lists & Counters
23.逻辑属性 | Logical Properties
24.面具 | Masking
25.媒体查询 | Media Queries
26.杂项 | Miscellaneous
27.Miscellaneous Level 1
28.Miscellaneous Level 2
29.运动路径 | Motion Path
30. 多列布局 | Multi-column Layout
31.命名空间 | Namespaces
32.项目模型 | Object Model View
33.网页媒体 | Paged Media
34.定位布局 | Positioned Layout
35.伪元素 | Pseudo-
36.节奏大小 | Rhythmic Sizing
37. Ruby布局 | Ruby Layout
38.可缩放矢量图形 | Scalable Vector Graphics
39.滚动快照 | Scroll Snap
40.选择 | Selectors
41.形状 | Shapes
42.文本 | Text
43.文字装饰 | Text Decoration
44.变换 | Transforms
45.值和单位 | Values & Units
46.变量 | Variables
47.写入模型 | Writing Modes
48.CSS 教程
49.CSS 创建
50.CSS Id 和 Class选择器
51.CSS 简介
52.CSS 盒子模型
53.CSS Table(表格)
54.CSS 列表样式(ul)
55.CSS 链接(link)
56.CSS Fonts(字体)
57.CSS Text(文本)
58.CSS Backgrounds(背景)
59.CSS Display(显示) 与 Visibility(可见性)
60.CSS 尺寸 (Dimension)
61.CSS 分组和嵌套
62.CSS 轮廓(outline)属性
63.CSS Border(边框)
64.CSS 图像透明/不透明
65.CSS 导航栏
66.CSS 伪元素
67.CSS 伪类
68.CSS Float(浮动)
69.CSS Position(定位)
70.CSS 总结
71.CSS 属性选择器
72.CSS 媒体类型
73.CSS 图像拼合技术
74.CSS 实例
75.CSS 组合选择符
76.响应式 Web 设计 – 框架
77.响应式 Web 设计 – 视频(Video)
78.CSS 提示工具(Tooltip)
79.CSS 布局 Overflow
80.CSS 计数器
81.CSS 表单