温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何使用css实现多个颜色渐变

发布时间:2022-01-20 14:53:53 来源:亿速云 阅读:688 作者:清风 栏目:web开发

这篇“如何使用css实现多个颜色渐变”文章,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要参考一下,对于“如何使用css实现多个颜色渐变”,小编整理了以下知识点,请大家跟着小编的步伐一步一步的慢慢理解,接下来就让我们进入主题吧。

  我在HTML中创建了常用按钮,并为它们提供了常用的类名和特定的类名以及一些样式来装饰按钮。

  HTML

  <aclass="buttonbutton1">button1</a>

  <aclass="buttonbutton2">button2</a>

  <aclass="buttonbutton3">button3</a>

  <aclass="buttonbutton4">button4</a>

  <aclass="buttonbutton5">button5</a>

  CSS

  .button{

  float:left;

  height:40px;

  line-height:40px;

  margin-right:20px;

  padding:015px;

  color:#fff;

  font-weight:bold;

  font-size:16px;

  font-family:arial;

  background-color:#555;

  border-radius:5px;border:solid1pxrgba(0,0,0,0.5);

  }

  给每个按钮独特的颜色(常规背景颜色)。

  CSS

  .button1{background-color:orange;}

  .button2{background-color:red;}

  .button3{background-color:green;}

  .button4{background-color:RoyalBlue;}

  .button5{background-color:OrangeRed;}

  现在,使所有这些渐变是很容易的。我没有使用全彩色进行渐变,如红色和深红色,而是使用背景色为黑色的渐变,不透明度为0%直到黑色背景色的不透明度为65%。

  然后将此渐变添加到常用按钮类的透明度中。

  CSS

  .button{

  background-image:linear-gradient(rgba(0,0,0,0)0%,rgba(0,0,0,0.65)100%);

  }

  好了,现在我们已经完成使用CSS中只有一个渐变来制作多个渐变色。

  完整代码:

  <!DOCTYPEhtml>

  <html>

  <head>

  <metacharset="utf-8">

  <title></title>

  <styletype="text/css">

  .button{

  float:left;

  height:40px;

  line-height:40px;

  margin-right:20px;

  padding:015px;

  color:#fff;

  font-weight:bold;

  font-size:16px;

  font-family:arial;

  background-color:#555;

  border-radius:5px;

  border:solid1pxrgba(0,0,0,0.5);

  background-image:linear-gradient(rgba(0,0,0,0)0%,rgba(0,0,0,0.65)100%);/*W3C*/

  }

  .button1{background-color:orange;}

  .button2{background-color:red;}

  .button3{background-color:green;}

  .button4{background-color:RoyalBlue;}

  .button5{background-color:OrangeRed;}

  </style>

  </head>

  <body>

  <aclass="buttonbutton1">button1</a>

  <aclass="buttonbutton2">button2</a>

  <aclass="buttonbutton3">button3</a>

  <aclass="buttonbutton4">button4</a>

  <aclass="buttonbutton5">button5</a>

  </body>

  </html>

css的全称是什么

css的全称是Cascading Style Sheets(层叠样式表),它是一种用来表现HTML或XML等文件样式的计算机语言。CSS不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。

以上是“如何使用css实现多个颜色渐变”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

css
AI