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

查看:11
本文介绍了是否有任何干净的 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.

设计者正在包含这样的文件对于每一页.我宁愿不必为每个页面手动生成图像,因为这会使非技术站点编辑器难以添加页面和更改页面名称.

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.

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>");
}

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

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