div上的CSS渐变背景

时间:2016-10-21 01:44:28

标签: html css

如何获得与下面活动div类似的风格?似乎颜色有点褪色。

enter image description here

2 个答案:

答案 0 :(得分:0)

您可以使用linear-gradient,因为它描述为here。您可以执行以下操作:

.hoverable:hover {
  background: -webkit-linear-gradient(white, lightgray);
  background: -moz-linear-gradient(white, lightgray);
  background: -o-linear-gradient(white, lightgray);
  background: linear-gradient(white, lightgray);
}

您可以在this Fiddle

上查看演示

答案 1 :(得分:0)

试试这个



#grad1 {
    height: 200px;
    background: -webkit-linear-gradient(left, rgba(255,0,0,0), rgba(255,0,0,1)); /* For Safari 5.1 to 6.0 */
    background: -o-linear-gradient(right, rgba(255,0,0,0), rgba(255,0,0,1)); /* For Opera 11.1 to 12.0 */
    background: -moz-linear-gradient(right, rgba(255,0,0,0), rgba(255,0,0,1)); /* For Firefox 3.6 to 15 */
    background: linear-gradient(rgba(255,0,0,0), rgba(245,245,245,1)); /* Standard syntax (must be last) */
}

<!DOCTYPE html>
<html>
<body>

<h3>Linear Gradient - Transparency</h3>

<div id="grad1"></div>

</body>
</html>
&#13;
&#13;
&#13;