无效的css[linear-gradient]写法

.loginbox{
    background-color: linear-gradient(#D0D0D0, #E0E0E0, white); 
    width: 300px;
}

  • 此CSS样式无法改变元素的背景色,是因为渐变色在CSS中被定义成了 image 类型,所以渐变色只可以用在需要图形数据的地方。因此linear-gradient在background-color与color中引用无效,要想实现操作可以直接写为background属性
.loginbox{
    background: linear-gradient(#D0D0D0, #E0E0E0, white); 
    width: 300px;
}

  • 如仍然无法显示,考虑浏览器兼容问题
    background: -webkit-linear-gradient(red, blue); /* Safari 5.1 - 6.0 */
    background: -o-linear-gradient(red, blue); /* Opera 11.1 - 12.0 */
    background: -moz-linear-gradient(red, blue); /* Firefox 3.6 - 15 */
    background: linear-gradient(red, blue); /* 标准的语法(必须放在最后) */

参考链接

未完,待续

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-05-06
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-20
  • 2021-10-22
  • 2021-12-16
  • 2022-01-12
  • 2021-10-14
  • 2022-12-23
  • 2021-12-12
相关资源
相似解决方案