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/