哪个是用于 CSS 渐变的正确属性?“背景”或“背景图像”,如下所示。它们都适用于所有 5 个浏览器(在我拥有的版本中)。我看过多个教程,有些使用“背景”,有些使用“背景图像”,但没有人讨论为什么一种方法比另一种更好。
他们都没有在http://jigsaw.w3.org/css-validator/#validate_by_input上验证
.gradient {
background-color: #1a82f7;
background: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727));
background: -webkit-linear-gradient(top, #2F2727, #1a82f7);
background: -moz-linear-gradient(top, #2F2727, #1a82f7);
background: -ms-linear-gradient(top, #2F2727, #1a82f7);
background: -o-linear-gradient(top, #2F2727, #1a82f7);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#2F2727, endColorstr=#1a82f7);
}
或者这个:
.gradient {
background-color: #1a82f7;
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#1a82f7), to(#2F2727));
background-image: -webkit-linear-gradient(top, #2F2727, #1a82f7);
background-image: -moz-linear-gradient(top, #2F2727, #1a82f7);
background-image: -ms-linear-gradient(top, #2F2727, #1a82f7);
background-image: -o-linear-gradient(top, #2F2727, #1a82f7);
filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0, startColorstr=#2F2727, endColorstr=#1a82f7);
}