2012-01-28 88 views
1

我正在使用CSS在我的文本上生成漸變...問題是我的文本是多行的,所以漸變不會在每一行上重置......整個段落變成1巨大梯度!我可以爲分隔線中的每一行文字獲得單獨的漸變效果嗎?這裏是我的代碼:CSS多線漸變文本。 -webkit-background-clip

<html> 
<head> 
<style type='text/css'>p.p1 { 
    margin: 0.0px 0.0px 0.0px 50.0px; 
    font: 50.0px Helvitica; 
    font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Helvetica, Arial', 'Lucida Grande', 'sans-serif'; 
    background: -webkit-gradient(linear, left top, left bottom, from(#eee), to(#333)); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
    } 
</style> 
</head> 
<body bgcolor='#FFFFFF'> 
<div style='word-wrap: break-word;'> 
<p class='p1'> 
<font face='helvetica' color='#000000'> 
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi id vestibulum lectus. Maecenas facilisis orci vitae urna pulvinar cursus. Etiam id laoreet metus. Cras vitae elit ipsum. Donec a sagittis nisi. Sed nec nisi nibh, fringilla fermentum quam. Vestibulum lorem felis, gravida et faucibus ac, ultrices nec lectus. 
</font> 
</p> 
</div> 
</body> 
</html> 

回答

1

我擺脫過時的標籤和清理的代碼爲你..

p.p1 { 
    margin: 0 0 0 50px; 
    font-size: 50px; 
    font-family: 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', 'Helvetica, Arial', 'Lucida Grande', 'sans-serif'; 
    background: -webkit-repeating-linear-gradient(top, red 0px, blue 60px); 
    -webkit-background-clip: text; 
    -webkit-text-fill-color: transparent; 
    } 

Demo

+0

VERY NICE!謝謝! :) – 2012-01-28 18:04:28

+0

它只適用於webkit – 2012-07-26 05:02:22