Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
CSS3透明度&x2B;坡度_Css_Gradient - Fatal编程技术网

CSS3透明度&x2B;坡度

CSS3透明度&x2B;坡度,css,gradient,Css,Gradient,RGBA非常有趣,-webkit gradient,-moz gradient,还有程序ID:DXImageTransform.Microsoft.gradient。。。是的。:) 有没有一种方法可以将RGBA和渐变结合起来,这样就可以使用当前/最新的CSS规范实现alpha透明度的渐变。有。您可以在webkit和moz渐变声明中使用rgba: /* webkit example */ background-image: -webkit-gradient( linear, left top,

RGBA非常有趣,
-webkit gradient
-moz gradient
,还有<代码>程序ID:DXImageTransform.Microsoft.gradient。。。是的。:)


有没有一种方法可以将RGBA和渐变结合起来,这样就可以使用当前/最新的CSS规范实现alpha透明度的渐变。

有。您可以在webkit和moz渐变声明中使用rgba:

/* webkit example */
background-image: -webkit-gradient(
  linear, left top, left bottom, from(rgba(50,50,50,0.8)),
  to(rgba(80,80,80,0.2)), color-stop(.5,#333333)
);
()

()

显然,您甚至可以在IE中使用奇怪的“扩展十六进制”语法来实现这一点。第一对(在示例55中)表示不透明度级别:

/* approximately a 33% opacity on blue */
filter: progid:DXImageTransform.Microsoft.gradient(
  startColorstr=#550000FF, endColorstr=#550000FF
);

/* IE8 uses -ms-filter for whatever reason... */
-ms-filter: progid:DXImageTransform.Microsoft.gradient(
  startColorstr=#550000FF, endColorstr=#550000FF
);

()

这真是太酷了!我需要几乎相同的,但水平梯度从白色到透明。它工作得很好!这是我的密码:

.gradient{
        /* webkit example */
        background-image: -webkit-gradient(
          linear, right top, left top, from(rgba(255, 255, 255, 1.0)),
          to(rgba(255, 255, 255, 0))
        );

        /* mozilla example - FF3.6+ */
        background-image: -moz-linear-gradient(
          right center,
          rgba(255, 255, 255, 1.0) 20%, rgba(255, 255, 255, 0) 95%
        );

        /* IE 5.5 - 7 */
        filter: progid:DXImageTransform.Microsoft.gradient(
          gradientType=1, startColor=0, endColorStr=#FFFFFF
        );

        /* IE8 uses -ms-filter for whatever reason... */
        -ms-filter: progid:DXImageTransform.Microsoft.gradient(
          gradientType=1, startColor=0, endColoStr=#FFFFFF
        );
    }

所有现代浏览器(从Chrome 26、Opera 12.1、IE 10和Firefox 16开始)都支持新语法

背景:线性渐变(到底部,rgba(0,0,0,1),rgba(0,0,0,0));
这将渲染渐变,从顶部的纯黑色开始,到底部的完全透明

.

这是我的代码:

background: #e8e3e3; /* Old browsers */
  background: -moz-linear-gradient(top,  rgba(232, 227, 227, 0.95) 0%, rgba(246, 242, 242, 0.95) 100%); /* FF3.6+ */
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgba(232, 227, 227, 0.95)), color-stop(100%,rgba(246, 242, 242, 0.95))); /* Chrome,Safari4+ */
  background: -webkit-linear-gradient(top,  rgba(232, 227, 227, 0.95) 0%,rgba(246, 242, 242, 0.95) 100%); /* Chrome10+,Safari5.1+ */
  background: -o-linear-gradient(top,  rgba(232, 227, 227, 0.95) 0%,rgba(246, 242, 242, 0.95) 100%); /* Opera 11.10+ */
  background: -ms-linear-gradient(top,  rgba(232, 227, 227, 0.95) 0%,rgba(246, 242, 242, 0.95) 100%); /* IE10+ */
  background: linear-gradient(to bottom,  rgba(232, 227, 227, 0.95) 0%,rgba(246, 242, 242, 0.95) 100%); /* W3C */
  filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='rgba(232, 227, 227, 0.95)', endColorstr='rgba(246, 242, 242, 0.95)',GradientType=0 ); /* IE6-9 */
我在w3schools中发现了这一点,并在寻找渐变和透明度时满足了我的需求。我提供的链接是指学校。希望这有助于任何人寻找梯度和透明度

我还尝试在w3schools中更改不透明度粘贴链接检查它


希望能有所帮助。

我刚刚遇到了这个最近的例子。为了简化和使用最新的示例,给css一个“grad”选择器类(我已经包括了向后兼容性)


以下是我用来为同一颜色生成从完全不透明(顶部)到20%透明度(底部)的垂直渐变:

background: linear-gradient(to bottom, rgba(0, 64, 122, 1) 0%,rgba(0, 64, 122, 0.8) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
background: -o-linear-gradient(top, rgba(0, 64, 122, 1) 0%, rgba(0, 64, 122, 0.8) 100%); /* Opera 11.10+ */
background: -moz-linear-gradient(top, rgba(0, 64, 122, 1) 0%, rgba(0, 64, 122, 0.8) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(0, 64, 122, 1) 0%,rgba(0, 64, 122, 0.8) 100%); /* Chrome10-25,Safari5.1-6 */
background: -ms-linear-gradient(top, rgba(0, 64, 122, 1) 0%,rgba(0, 64, 122, 0.8) 100%); /* IE10+ */
-ms-filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00407a', endColorstr='#cc00407a',GradientType=0 ); /* IE8 */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00407a', endColorstr='#cc00407a',GradientType=0 ); /* IE 5.5 - 9 */

仅供参考,“扩展十六进制”只是32位ARGB而不是24位RGB颜色值。我希望这些颜色值也能在标准css中使用,但在末尾使用alpha(似乎更自然):
0001
将是“几乎透明的黑色”的短十六进制,
ffcc00ff
将与
ffcc00
相同,即。“完全不透明的橘黄色”还可以查看,它有一系列很好的预设和所有跨浏览器兼容的变体,以实现您所需的渐变。因此,我已经查看了它,它适用于所有主要浏览器,但不适用于opera,有什么线索吗?没关系,我刚刚找到;)
背景图像:-o-linear-gradient(顶部,rgba(255255,0),rgba(210230250,1));
作为参考,在Microsoft实现中,gradientType=1是水平的,0是垂直的。IE7和IE8渐变没有指定任何alpha颜色?它们真的会褪色为透明吗?在顶部创建纯黑色,在底部完全透明我想这是一个建议,实际上不起作用吗?背景:线性渐变(向左,rgba(0,0,0,1),rgba(0,0,0,0));//对于从左到右的渐变背景:线性渐变(向右,rgba(0,0,0,1),rgba(0,0,0,0));//对于从右到左gradient@geo1701他的评论应该被接受,因为它更符合现代标准。
#grad
{
    background: -webkit-linear-gradient(left,rgba(255,0,0,0),rgba(255,0,0,1)); /*Safari 5.1-6*/
    background: -o-linear-gradient(right,rgba(255,0,0,0),rgba(255,0,0,1)); /*Opera 11.1-12*/
    background: -moz-linear-gradient(right,rgba(255,0,0,0),rgba(255,0,0,1)); /*Fx 3.6-15*/
    background: linear-gradient(to right, rgba(255,0,0,0), rgba(255,0,0,1)); /*Standard*/
}
.grad {
    background-color: #F07575; /* fallback color if gradients are not supported */
    background-image: -webkit-linear-gradient(top left, red, rgba(255,0,0,0));/* For Chrome 25 and Safari 6, iOS 6.1, Android 4.3 */
    background-image: -moz-linear-gradient(top left, red, rgba(255,0,0,0));/* For Firefox (3.6 to 15) */
    background-image: -o-linear-gradient(top left, red, rgba(255,0,0,0));/* For old Opera (11.1 to 12.0) */
    background-image: linear-gradient(to bottom right, red, rgba(255,0,0,0)); /* Standard syntax; must be last */
}
background: linear-gradient(to bottom, rgba(0, 64, 122, 1) 0%,rgba(0, 64, 122, 0.8) 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */
background: -o-linear-gradient(top, rgba(0, 64, 122, 1) 0%, rgba(0, 64, 122, 0.8) 100%); /* Opera 11.10+ */
background: -moz-linear-gradient(top, rgba(0, 64, 122, 1) 0%, rgba(0, 64, 122, 0.8) 100%); /* FF3.6-15 */
background: -webkit-linear-gradient(top, rgba(0, 64, 122, 1) 0%,rgba(0, 64, 122, 0.8) 100%); /* Chrome10-25,Safari5.1-6 */
background: -ms-linear-gradient(top, rgba(0, 64, 122, 1) 0%,rgba(0, 64, 122, 0.8) 100%); /* IE10+ */
-ms-filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00407a', endColorstr='#cc00407a',GradientType=0 ); /* IE8 */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#00407a', endColorstr='#cc00407a',GradientType=0 ); /* IE 5.5 - 9 */