Exp*_*lls 44
CSS表达式(通过CSS允许动态脚本内容)是与Web Forms一起在低效率地狱中流淌的可憎之物,只有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>
Run Code Online (Sandbox Code Playgroud)
bde*_*ham 28
这在CSS中是不可能的,这是确定性的.但是,您可以使用客户端JavaScript执行此操作:
var colors = ['#ff0000', '#00ff00', '#0000ff'];
var random_color = colors[Math.floor(Math.random() * colors.length)];
document.getElementById('title').style.color = random_color;
Run Code Online (Sandbox Code Playgroud)
如果您正在使用jQuery,最后一行可能会成为
$('#title').css('color', random_color);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
59966 次 |
| 最近记录: |