この記事では、マウスが点滅するときに回転カラーブロックを実装するJSの方法について説明します。参照のためにそれを共有してください。特定の実装方法は次のとおりです。
次のようにコードをコピーします:<html>
<head>
<title> jsは、マウスの点滅する色ブロックに従います</title>
</head>
<body>
<スクリプト言語= "javascript">
<! -
if(document.all){
colors = new Array( 'ff0000'、 '00ff00'、 '3366ff'、 'ff00ff'、 'fffa500'、 'ffffff'、 'ffff000'))
量= colours.length;
ygetdelay = 0、xgetdelay = 0、ydelay = 0、xdelay = 0、step = 0.2、currstep = 0、my = 0、mx = 0;
document.write( '<div id = "ie" style = "position:absolute; top:0; left:0;"> <div style = "position:relative">');
for
document.write( '<div id = "iestars" style = "position:absolute; top:0px; left:0px; height:50px; width:50px; font-family:courier new; font-size:5px; color:'+colors [i]+'; padding-top:20px; text-align:center"> </div>');
document.write( '</div> </div>');
ini = 1;
GSTEP = 1;
関数imouse(){
my = event.y; mx = event.x;
}
document.onmousemove = imouse
function dim(){
ini- = gStep;
dt = setimeout( 'dim()'、10);
if(ini <2){
ClearTimeout(dt);
glow();
}
}
functionglow(){
ini+= gStep;
gt = setimeout( 'glow()'、10);
if(ini> 14){
ClearTimeout(GT);
dim();
}
}
function stars(){
ie.style.top = document.body.scrolltop;
for
{
var layer = iestars [i] .style;
layer.filter = 'glow(color ='+colors [i]+'、strength ='+ini+')';
layer.top = ydelay+100*math.sin((5*math.sin((currstep-15.99)/10))+i*70)*math.sin((currStep)/10)*math.cos((currStep+i*25)/10);
layer.left = xdelay+180*math.cos((5*math.sin((currstep-15.99)/10)+i*70)*math.sin((currStep)/10)*math.cos((currStep+i*25)/10);
}
CurrStep+= step;
}
function delay(){
ydelay = ygetdelay+=(my-ygetdelay)*1/20;
xdelay = xgetdelay+=(mx-xgetdelay)*1/20;
星();
setimeout( 'delay()'、10);
}
遅れ();
glow();
}
//->
</script>
</body>
</html>
この記事がみんなのJavaScriptプログラミングに役立つことを願っています。