文字围绕鼠标旋转并移动(滚轮控制半径)

网上看到的字符旋转效果,加以改动跟随鼠标旋转并移动,滚轮控制旋转圆到横向直径和纵向直径:

  1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  2 <html>
  3 <head>
  4 <META content="text/html; charset=gb2312" http-equiv=Content-Type>
  5 <META name=GENERATOR content="MSHTML 8.00.7600.17051">
  6 <title>Insert title here</title>
  7 </head>
  8 <body onload="setting()">
  9 <DIV
 10     style="POSITION: absolute;font-weight:bold;"
 11     id="Circle0">
 12 <P><FONT COLOR = steelblue size=4>你</FONT></P>
 13 </DIV>
 14 <DIV
 15     style="POSITION: absolute;font-weight:bold;"
 16     id="Circle1">
 17 <P><FONT COLOR = steelblue size=4>是</FONT></P>
 18 </DIV>
 19 <DIV
 20     style="POSITION: absolute;font-weight:bold;"
 21     id=Circle2>
 22 <P><FONT COLOR = steelblue size=4>我</FONT></P>
 23 </DIV>
 24 <DIV
 25     style="POSITION: absolute;font-weight:bold;"
 26     id=Circle3>
 27 <P><FONT COLOR = steelblue size=4>的</FONT></P>
 28 </DIV>
 29 <DIV
 30     style="POSITION: absolute;font-weight:bold;"
 31     id=Circle4>
 32 <P><FONT color=#ff0000 size=4>小</FONT></P>
 33 </DIV>
 34 <DIV
 35     style="POSITION: absolute;font-weight:bold;"
 36     id=Circle5>
 37 <P><FONT color=#ff0000 size=4>呀</FONT></P>
 38 </DIV>
 39 <DIV
 40     style="POSITION: absolute;font-weight:bold;"
 41     id=Circle6>
 42 <P><FONT color=#ff0000 size=4>小</FONT></P>
 43 </DIV>
 44 <DIV
 45     style="POSITION: absolute;font-weight:bold;"
 46     id=Circle7>
 47 <P><FONT color=#ff0000 size=4>苹</FONT></P>
 48 </DIV>
 49 <DIV
 50     style="POSITION: absolute;font-weight:bold;"
 51     id=Circle8>
 52 <P><FONT color=#ff0000 size=4>果</FONT></P>
 53 </DIV>
 54 <DIV
 55     style="POSITION: absolute;font-weight:bold;"
 56     id=Circle9>
 57 <P><FONT color=#008000 size=4>*</FONT></P>
 58 </DIV>
 59 <DIV
 60     style="POSITION: absolute;font-weight:bold;"
 61     id=Circle10>
 62 <P><FONT color=#8080ff size=4>怎</FONT></P>
 63 </DIV>
 64 <DIV
 65     style="POSITION: absolute;font-weight:bold;"
 66     id=Circle11>
 67 <P><FONT color=#8080ff size=4>么</FONT></P>
 68 </DIV>
 69 <DIV
 70     style="POSITION: absolute;font-weight:bold;"
 71     id=Circle12>
 72 <P><FONT color=#8080ff size=4>爱</FONT></P>
 73 </DIV>
 74 <DIV
 75     style="POSITION: absolute;font-weight:bold;"
 76     id=Circle13>
 77 <P><FONT color=#8080ff size=4>你</FONT></P>
 78 </DIV>
 79 <DIV
 80     style="POSITION: absolute;font-weight:bold;"
 81     id=Circle14>
 82 <P><FONT color=#8080ff size=4>都</FONT></P>
 83 </DIV>
 84 <DIV
 85     style="POSITION: absolute;font-weight:bold;"
 86     id=Circle15>
 87 <P><FONT color=#8080ff size=4>不</FONT></P>
 88 </DIV>
 89 <DIV
 90     style="POSITION: absolute;font-weight:bold;"
 91     id=Circle16>
 92 <P><FONT color=#8080ff size=4>嫌</FONT></P>
 93 </DIV>
 94 <DIV
 95     style="POSITION: absolute;font-weight:bold;"
 96     id=Circle17>
 97 <P><FONT color=#8080ff size=4>多</FONT></P>
 98 </DIV>
 99 <DIV
100     style="POSITION: absolute;font-weight:bold;"
101     id=Circle18>
102 <P><FONT color=#008000 size=4>*</FONT></P>
103 </DIV>
104 <DIV
105     style="POSITION: absolute;font-weight:bold;"
106     id=Circle19>
107 <P><FONT color=#ff0000 size=4>就</FONT></P>
108 </DIV>
109 <DIV
110     style="POSITION: absolute;font-weight:bold;"
111     id=Circle20>
112 <P><FONT color=#ff0000 size=4>这</FONT></P>
113 </DIV>
114 <DIV
115     style="POSITION: absolute;font-weight:bold;"
116     id=Circle21>
117 <P><FONT color=#ff0000 size=4>样</FONT></P>
118 </DIV>
119 <DIV
120     style="POSITION: absolute;font-weight:bold;"
121     id=Circle22>
122 <P><FONT color=#ff0000 size=4>走</FONT></P>
123 </DIV>
124 <DIV
125     style="POSITION: absolute;font-weight:bold;"
126     id=Circle23>
127 <P><FONT color=#ff0000 size=4>进</FONT></P>
128 </DIV>
129 <DIV
130     style="POSITION: absolute;font-weight:bold;"
131     id=Circle24>
132 <P><FONT color=#ff0000 size=4>心</FONT></P>
133 </DIV>
134 <DIV
135     style="POSITION: absolute;font-weight:bold;"
136     id=Circle25>
137 <P><FONT color=#ff0000 size=4>窝</FONT></P>
138 </DIV>
139 <DIV
140     style="POSITION: absolute;font-weight:bold;"
141     id=Circle26>
142 <P><FONT color=#008000 size=4>*</FONT></P>
143 </DIV>
144
145 <script>
146     var CenterX=100, CenterY=100, Pi, Inc;
147     var Circle = new Array();
148     var Pos = new Array();
149     var Rx = 2.0,Ry = 1.0;
150
151     function doMouseMove(e) {
152         var evt = e||window.event;
153         var x = evt.clientX || evt.x;
154         var y = evt.clientY || evt.y;
155         CenterX=x;
156         CenterY=y;
157
158     }
159
160     function doMouseWheel(e){
161         var evt = e||window.event;
162         if(evt.wheelDelta>0){
163             Rx = Rx - 0.1;
164             Ry = Ry + 0.1;
165         }else{
166             Rx = Rx + 0.1;
167             Ry = Ry - 0.1;
168         }
169     }
170
171     function setting() {
172         for (i = 0; i <= 26; i++)
173             Circle[i] = eval("document.getElementById(‘Circle" + i + "‘)" + ".style");
174
175         Radius = 160;
176         Pi = Math.PI;
177         Inc = Pi / 180;
178
179         Pos[0] = 0;
180         for (i = 1; i < Circle.length; i++)
181             Pos[i] = parseFloat(Pos[i - 1] + ((2 * Pi) / Circle.length));
182         for (i = 0; i < Pos.length; i++) {
183             Pos[i] = Pos[i] + Inc;
184             Circle[i].left = Radius * Math.cos(Pos[i]) + CenterX;
185             Circle[i].top = Radius * Math.sin(Pos[i]) + CenterY;
186         }
187         setInterval("Last()", 10);
188     }
189
190     function Last() {
191         for (i = 0; i < Pos.length; i++) {
192             Circle[i].visibility = "visible";
193         }
194
195         for (i = 0; i < Pos.length; i++) {
196             Pos[i] = Pos[i] + Inc;
197             Circle[i].left = Rx * Radius * Math.cos(Pos[i]) + CenterX;
198             Circle[i].top = Ry * Radius * Math.sin(Pos[i]) + CenterY;
199         }
200     }
201
202     document.onmousemove = doMouseMove;
203     document.onmousewheel = doMouseWheel;
204 </script>
205 </body>
206 </html>

关于兼容性,在IE和Opera中实现了,但在Chrome中没实现,Firefox和Safari本人没安装,没进行测试。

继续努力中...

时间: 2024-11-14 11:15:23

文字围绕鼠标旋转并移动(滚轮控制半径)的相关文章

围绕鼠标旋转的炫酷三叶空间旋浆效果

<html><head><title>围绕鼠标旋转的三叶空间旋浆</title><meta content="text/html; charset=gb2312" http-equiv="Content-Type"></head><body bgColor="#000000"><scriptlanguage="JavaScript">

这段代码为什么调不出来?文字围绕鼠标转

<html><head> <title>围绕鼠标转动的文字</title> <meta charset="UTF-8"/> <style> body, td, div { font-family: Verdana; font-size: 9pt } </style></head><body> <script language="JavaScript"&g

js鼠标控制图片的特效,滚轮控制放大、缩小、鼠标拖动、聚焦。。。

项目需要做一个js控制图片的特效,滚轮控制放大.缩小.鼠标拖动等效果,网上找方法,各种报错.不兼容...最终自己研究出一套方案如下: 代码直接从项目中拷了,就不整理格式了 <script type="text/javascript"> //图片特效 by jifei_mei //图片大小,记录放大或缩小图片前的大小 var pic_size = { width:0, height:0 }; //绑定滚轮滚动事件 if (window.addEventListener) {

html5 canvas围绕中心点旋转

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-

jQuery---鼠标滚轮控制div横向滚动条左右移动

HTML <div class="table-responsive"> <div class="fhtable" style="width:2000px"></div> </div> JavaScript //鼠标滚轮控制div左右移动 $(".fhtable").each(function(index,element) { element.onwheel = function(

定时器实现的地球围绕太阳旋转

一个地球围绕太阳旋转 1 #import "HUAppDelegate.h" 2 3 #define CENTER_X 160 4 #define CENTER_Y 240 5 #define RADIUS 130 6 7 @implementation HUAppDelegate 8 9 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)laun

poj 1106(半圆围绕圆心旋转能够覆盖平面内最多的点)

Transmitters Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4955   Accepted: 2624 Description In a wireless network with multiple transmitters sending on the same frequencies, it is often a requirement that signals don't overlap, or at

JS跟随鼠标旋转的图片

<html> <head> <title>JS跟随鼠标旋转的图片丨Daniel wellington</title> <script> <!-- Beginning of JavaScript - var x,y var step=5 var flag=1 var pause var timersmall var timerbig var isbigcircle=1 var pause=50 var bigradius var smallr

CSS文字被鼠标选中后的文字颜色及背景

::selection {background:#FF9; color:#F00;}::-moz-selection {background:#FF9; color:#F00;}::-webkit-selection {background:#FF9; color:#F00;} CSS文字被鼠标选中后的文字颜色及背景