html - CSS 从数组中选择一个随机颜色

标签 html css

CSS 中是否有一种方法可以让它从数组中随机选择字体颜色?我知道我可以用服务器端或 javascript 来做到这一点,但我想知道是否有纯 CSS 方法来做到这一点。

最佳答案

CSS 表达式(允许通过 CSS 动态脚本内容)是与 Web 表单一起在效率低下的 hell 深处投下的可憎之物,仅被 IE7 及以下版本支持。但既然你问了。

<style>
blink marquee {
   color: expression("rgb(" + Math.floor(Math.random() * 255)
      + "," + Math.floor(Math.random() * 255) + ","
      + Math.floor(Math.random() * 255) + ")");
}
</style>
<blink>
   <marquee>
      color me beautiful
   </marquee>
</blink>

关于html - CSS 从数组中选择一个随机颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14984643/

相关文章:

javascript - 一个 div 标签有 z-index :2 how to change sub div tag z-index:3

javascript - 如果我的用户有 ie6 该怎么办

javascript - 未捕获的 TypeError : document. getElementById(...).submit 不是函数

html - 是否可以部分覆盖该元素,但使其对光标可见?

css - div之间的空格?

javascript - 防止单击时打开多个弹出窗口

html - 如何控制select标签的宽度?

javascript - 哪些主题更改可能导致 BigCommerce 快速搜索无法运行?

html - 将一个段落元素移动到另一个段落元素旁边

HTML 元素未关注选项卡但可访问 shift+tab