简体   繁体   English

CSS线性渐变规则

[英]css linear gradient rule

I found this lying around: 我发现这周围:

background-image: -moz-linear-gradient(center top, #B6D3F4, #5483B8);

I assume the 2nd and 3rd params are the start and end color of the gradient, but what exactly does the first param "center top" mean? 我假定第二和第三参数是渐变的开始和结束颜色,但是第一个参数“中心顶部”到底是什么意思?

Given that -moz-linear-gradient is obviously specific to Mozilla, what's the equivalent CSS3 standard version of this rule? 鉴于-moz-linear-gradient显然特定于Mozilla,该规则的等效CSS3标准版本是什么?

Please have a look to the MDN . 请看一下MDN If I read right you can obmit the prefix. 如果我没看错,您可以忽略前缀。

<side-or-corner> <角或角>

Represents the position of the starting-point of the gradient line. 代表渐变线起点的位置。 It consists of two keywords: the first one indicates the horizontal side, left or right, and the second one the vertical side, top or bottom. 它由两个关键字组成:第一个关键字指示水平边(左侧或右侧),第二个关键字指示垂直边(顶部或底部)。 The order is not relevant and each of the keyword is optional. 顺序无关紧要,每个关键字都是可选的。

The values to top, to bottom, to left and to right are translated into the angles 0deg, 180deg, 270deg, 90deg respectively. 顶部,底部,左侧和右侧的值分别转换为角度0度,180度,270度和90度。 The others are translated into an angle that let the starting-point to be in the same quadrant than the described corner and so that the line defined by the starting-point and the corner is perpendicular to the gradient line. 其他的则转换为一个角度,该角度使起点与所描述的拐角处在同一象限中,从而使起点和拐角所定义的线垂直于渐变线。 That way, the color described by the <color-stop> will exactly apply to the corner point. 这样,<color-stop>描述的颜色将准确地应用于角点。 This is sometimes called the "magic corner" property. 有时称为“魔角”属性。 The end-point of the gradient line is the symmetrical point of the starting-point on the other direction of the center box. 渐变线的终点是中心框另一方向上起点的对称点。

For all browsers: 对于所有浏览器:

background: #b6d3f4; /* Old browsers */
background: -moz-linear-gradient(top,  #b6d3f4 0%, #5483b8 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#b6d3f4), color-stop(100%,#5483b8)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top,  #b6d3f4 0%,#5483b8 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top,  #b6d3f4 0%,#5483b8 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top,  #b6d3f4 0%,#5483b8 100%); /* IE10+ */
background: linear-gradient(top,  #b6d3f4 0%,#5483b8 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#b6d3f4', endColorstr='#5483b8',GradientType=0 ); /* IE6-9 */

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM