【发布时间】:2013-05-31 19:38:01
【问题描述】:
我正在使用来自Animating a CSS gradient background on the hover event 的以下代码,这太棒了。但是,我希望渐变从左到右。
.gradient {
background: -webkit-linear-gradient(lightgray,white);
background: -moz-linear-gradient(lightgray,white);
background: -o-linear-gradient(lightgray,white);
background: linear-gradient(lightgray,white);
-webkit-transition: background 1s ease-out;
-moz-transition: background 1s ease-out;
-o-transition: background 1s ease-out;
transition: background 1s ease-out;
-moz-background-size: 1px 200px;
-o-background-size: 1px 200px;
-webkit-background-size: 1px 200px;
background-size: 1px 200px;
cursor: pointer;
}
.gradient:Hover {
background-position: 100px;
}
我尝试添加 left 并用 background-image 替换背景,如下所述:http://www.webdirections.org/blog/css3-linear-gradients/
.gradient {
background: -webkit-linear-gradient(left, lightgray,white);
background: -moz-linear-gradient(left, lightgray,white);
background: -o-linear-gradient(left, lightgray,white);
background: linear-gradient(left, lightgray,white);
-webkit-transition: background 1s ease-out;
-moz-transition: background 1s ease-out;
-o-transition: background 1s ease-out;
transition: background 1s ease-out;
-moz-background-size: 1px 200px;
-o-background-size: 1px 200px;
-webkit-background-size: 1px 200px;
background-size: 1px 200px;
cursor: pointer;
}
.gradient:Hover {
background-position: 100px;
}
还是没有骰子。
【问题讨论】: