有没有任何干净的CSS方法使一个单词中的每个字母是不同的颜色? [英] Is there any clean CSS method to make each letter in a word a different color?

查看:1022
本文介绍了有没有任何干净的CSS方法使一个单词中的每个字母是不同的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一种方式允许一个单词的每个字母通过3种不同的颜色旋转。我知道一些不那么干净的方式,我可以这样做与asp.net,但我想知道是否可能有一个更清洁的CSS / JavaScript解决方案,更多的搜索引擎友好。

I need a way to allow each letter of a word to rotate through 3 different colors. I know of some not so clean ways I can do this with asp.NET, but I'm wondering if there might be a cleaner CSS/JavaScript solution that is more search engine friendly.

设计师包括这样的文件< a>。我不想为每个页面手动生成图像,因为非技术网站编辑人员很难添加页面和更改页面名称。

The designer is including a file like this for each page. I'd rather not have to manually generate an image for every page as that makes it hard for the non-technical site editors to add pages and change page names.

推荐答案

这是一些JavaScript。

Here is some JavaScript.

<script type="text/javascript">
   var message = "The quick brown fox.";
   var colors = new Array("#ff0000","#00ff00","#0000ff"); // red, green, blue
   for (var i = 0; i < message.length; i++)
      document.write("<span style=\"color:" + colors[(i % colors.length)] + ";\">" + message[i] + "</span>");
</script>

这篇关于有没有任何干净的CSS方法使一个单词中的每个字母是不同的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆