简体   繁体   English

不清楚CSS3梯度中百分比%的迹象

[英]Unclear about percentage % signs in CSS3 gradients

I am studying about CSS3 gradients ( Link ). 我正在研究CSS3渐变( 链接 )。 I am unable to understand the following syntax 我无法理解以下语法

  /* Firefox 3.6 to 15 */
  background: -moz-linear-gradient(red, yellow 10%, green 20%);

Can anybody tell me what % signs do? 谁能告诉我%标志有什么作用? What are their ranges? 它们的范围是多少? Should 2nd Percentage value (green 20%) be always greater than first percentage value (yellow %)? 第二个百分比值(绿色20%)是否应始终大于第一个百分比值(黄色%)? And why there is no percentage sign with red color? 为什么没有红色的百分号?

The percentage tells us what point it gradients to that color by. 百分比告诉我们它渐变到那个颜色的点。 If you change yellow to 50%, it will gradient from red to yellow at the 50% point. 如果将黄色变为50%,它将在50%点从红色渐变到黄色。 If you give a percent value to red, the red won't start till that percent value, with the start being a solid of the final gradient color. 如果您将百分比值指定为红色,则红色将不会在该百分比值之前开始,并且开始是最终渐变颜色的实体。 If the third gradient color percentage is less than the second, then it won't show up. 如果第三个渐变颜色百分比小于第二个,则它不会显示。 If the total values are less than 100% it will repeat that gradient pattern until 100% is accounted for. 如果总值小于100%,则将重复该梯度模式,直到考虑100%。

Here percentage sign is use the to fill the background color correspondingly. 这里百分号用于相应地填充背景颜色。 If you have syntax, 如果你有语法,

background: -moz-linear-gradient(red, yellow 10%, green 20%);

It shows that it is started with red color first and the background is red when if you add yellow 10% now the whole background will be 1/10 of the the red means now red cover only 10% and the other 90% will be yellow, and when if you add green 20% then yellow and red will goes to 20% and other 80% will be of green and here 20% will divide into two parts one is actually define that is 10% of yellow and the red automatically set to other 10%. 它显示它首先以红色开始,背景为红色,如果你加黄色10%,现在整个背景将是红色的1/10,现在红色仅覆盖10%,另外90%将是黄色,如果你加绿色20%,那么黄色和红色将变为20%,其他80%将变为绿色,这里20%将分为两个部分,一个实际定义为10%的黄色和红色自动设置其他10%。

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

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