<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title>菜鸟教程(runoob.com)</title> 
<style>
#grad1 {
    height: 200px;

    background: linear-gradient(to left, rgba(255,0,0,0), rgba(255,0,0,1)); /* 标准的语法(必须放在最后) */
}
#grad2 {
   height: 200px;

   background: linear-gradient(to top, rgba(255,0,0,0), rgba(255,0,0,1)); /* 标准的语法(必须放在最后) */
}


body {
    background-image: linear-gradient(to right top, #ffcc00 50%, #eee 50%);
    background-repeat: no-repeat;
}
</style>
</head>
<body>

<h3>线性渐变 - 透明度</h3>
<p>为了添加透明度,我们使用 rgba() 函数来定义颜色结点。rgba() 函数中的最后一个参数可以是从 0 到 1 的值,它定义了颜色的透明度:0 表示完全透明,1 表示完全不透明。</p>

<div >从右边向左边透明变成红色</div>
<div >从底部到顶部透明变成红色</div>

<p><strong>注意:</strong> Internet Explorer 9 及之前的版本不支持渐变。</p>

</body>
</html>

相关文章:

  • 2021-12-05
  • 2022-12-23
  • 2022-01-15
  • 2021-04-09
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-04
猜你喜欢
  • 2022-01-13
  • 2022-02-19
  • 2021-10-08
  • 2022-02-11
  • 2021-04-24
  • 2021-04-07
  • 2021-06-08
相关资源
相似解决方案