2016-08-30 52 views
-1

我希望有人可以帮助我知道一点点htmlcss。 我正在寻找一种方法来从左向右更改单词的颜色。如果我能改变改变单词颜色的时间,那将是非常棒的。 (这可以在代码中,不需要用户输入)。如何更改css中单词的颜色从左到右

一个示例词将是 “Hello”(从黑色开始,然后从左到右依次为灰色)。 如果有人可以帮助....感谢

+1

欢迎来到堆栈溢出!预计你至少试图为自己编码。堆栈溢出不是代码写入服务。我建议你做一些[**额外的研究**](http://meta.stackoverflow.com/questions/261592/how-much-research-effort-is-expected-of-stack-overflow-users) ,无论是通过谷歌或通过搜索,尝试和。如果您仍然遇到麻烦,请返回**您的代码**并解释您尝试过的以及为什么它不起作用。 –

+0

我是否理解你想用渐变做文本,而不是背景? – Qwertiy

+0

http://lea.verou.me/2012/05/text-masking-the-standards-way/ – Qwertiy

回答

-1

编辑:更改文本颜色从从右向左移动

<html><head> 
<style> 
div.a {color:black;position:absolute;right:0} 
</style> 
<script src=jquery.js></script> 
<script src=jquery-ui.min.js></script> 
</head><body> 
<div class=a >Hello</div> 

<script> 
$(document).ready(function(){ 


$('div.a').animate({ 
    right: window.innerWidth - 50,  // move from right to left 
    color: "red"      // change color 
    }, 10000);       // time in ms 10000ms -> 10s 


}); 
</script> 
</body></html> 
1

Webkit的浏览器只有当:

body { 
 
    font-size: 4em; 
 
} 
 

 
div { 
 
    display: inline-block; 
 
    color: green; 
 
} 
 

 
@supports (-webkit-background-clip: text) { 
 
    div { 
 
    background: linear-gradient(to right, green, red); 
 
    -webkit-background-clip: text; 
 
    color: transparent; 
 
    } 
 
}
<div>Some text goes here</div>