css CSS Alpha透明度和渐变

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css CSS Alpha透明度和渐变相关的知识,希望对你有一定的参考价值。

GRADIENTS

LINEAR
background-image: linear-gradient(topcolor, bottomcolor); //top to bottom
background-image: linear-gradient(to top, bottomcolor, topcolor); //bottom to top
background-image: linear-gradient(to left, leftcolor, rightcolor); //right to left
background-image: linear-gradient(45deg, bottomleftcolor, toprightcolor); //angel bottom-left to top-right

RADIAL




/*
rgba(255, 255, 255, 0.8)
0=transparent, 1=opaque

Must have 2 containers: 1 to apply bg-img and 1 to appy the color and maybe a 3rd layer for text.
Follows the z-index rules.

<div class="image-bg">
  <div class="alpha-bg">
    <p>Just some text.</p>
  </div>
</div>
*/

.image-bg {
  width: 400px;
  font-family: Helvetica, Arial, sans-serif;
  line-height: 1.5;
  
  /* sets the background image */
  background: url(https://unsplash.it/400/300) no-repeat;
  
  /* sets gradient and image */
  background: linear-gradient(rgba(255, 255, 255, 0.8),
                 rgba(199,21,133, 0.5)),
                 url(https://unsplash.it/400/300) no-repeat;
}

.alpha-bg {
  padding: 20px;
  height: 100%;
  color: #eeeeee;
  
  /* sets the color with alpha transparency */
  background: rgba(70,130,180, 0.8);
}

/*
If you don't have a second container to apply the color styles to just use multiple background images instead and a GRADIENT.
*/

/*shorthand*/
background: url(image1.png) no-repeat top right,
            url(image2.png) no-repeat bottom left;

/*longhand*/
background-image: url(image1.png), url(image2.png);
background-repeat: no-repeat, no-repeat;
background-position: top right, bottom left;

/*
To overlay a color
*/
selector {
  background: linear-gradient(rgba-top-color, rgba-bottom-color); //use same values if you don't want gradient
              url(image.png);
}

以上是关于css CSS Alpha透明度和渐变的主要内容,如果未能解决你的问题,请参考以下文章

android标题栏透明度渐变

css3透明度与过度属性

css3新增的属性都有哪些

css中如何使透明度渐变

CSS 实现图片透明度渐变效果

CSS背景渐变