简体   繁体   English

CSS中从透明到颜色的渐变

[英]Gradient from transparent to color in CSS

My Boss give me an image (please see below) and told him I would make his site look the same. 我的老板给了我一张图片(请看下面)并告诉他我会让他的网站看起来一样。 Here is my code, but it doesn't look like the image: 这是我的代码,但它看起来不像图像:

HTML HTML

<div class="clearfix" id="footer">
  <ul>
    <li><a href="/pages/facility">Become a Virtual Active Facility</a></li>
    <li><a href="/pages/about">About Us</a></li>
    <li class="last"><a href="/pages/contact">Contact</a></li>
  </ul>
</div>

CSS CSS

#footer {
    background: -moz-linear-gradient(left center, white, white) repeat scroll 0 0 transparent;
    margin-bottom: 25px;
    margin-top: 25px;
    opacity: 0.6;
    padding: 10px 25px;
    width: 914px;
}

替代文字

How can I get the result to look the same? 如何才能使结果看起来一样?

Your gradient is defined as going from 'white' to 'white'. 您的渐变定义为从“白色”变为“白色”。 In other words, there is no gradient. 换句话说,没有梯度。

In the final 2014 syntax: 在2014年的最终语法中:

background-image: linear-gradient(to right, transparent, white);

Note that prefixed versions (moz-, webkit-, o-, etc) use a different syntax, for backwards compatibility. 请注意,前缀版本(moz-,webkit-,o-等)使用不同的语法,以实现向后兼容性。

试试吧:

background: -moz-linear-gradient(left center, transparent, white) repeat scroll 0 0 transparent;

你需要使用alpha(rgba)看看,可以帮到你: CSS3 Transparency + Gradient

This one works for me 这个对我有用

background: -moz-linear-gradient(
                left,
                rgba(0,0,0,0.001) 0%,
                rgba(201,201,201,1) 50%,
                rgba(0,0,0,0.001) 100%
                );

I use it to add some fade effect on both side of my hr 我用它在我的hr的两侧添加一些淡入淡出效果

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

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