日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 编程资源 > 编程问答 >内容正文

编程问答

html线条绕圆旋转,js围绕圆旋转

發(fā)布時(shí)間:2025/3/21 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 html线条绕圆旋转,js围绕圆旋转 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

其實(shí)利用以前學(xué)過(guò)的三角函數(shù)的知識(shí)就可以解這道題

html

click meclick meclick me

css

html,body{

margin: 0;

padding: 0;

width: 100%;

height: 100%;

}

.box-wrap{

display: flex;

justify-content: space-around;

align-items: center;

width: 100%;

height: 100%;

}

.box{

width: 100px;

height: 100px;

background-color: #009a61;

border-radius: 50%;

text-align: center;

line-height: 100px;

color: #fff;

cursor: pointer;

}

.round{

border-radius: 50%;

position: absolute;

background-color: #009a61;

}

js

var app = {

init: function () {

this.move();

},

cEle: function (tagName, iClass) {

var tag = document.createElement(tagName);

tag.className = iClass ? iClass : '';

return tag;

},

css: function (ele, styles) {

for(var attr in styles){

ele['style'][attr] = styles[attr];

}

},

round: function (ele, x, y, r) {

var deg = 0;

var timer = null;

var _this = this;

var w = ele.offsetWidth;

var h = ele.offsetHeight;

var a,b;

clearInterval(timer);

timer = setInterval(function () {

deg += 2;

a = Math.sin(deg * Math.PI/180) * r;

b = Math.cos(deg * Math.PI/180) * r;

_this.css(ele, {

left: (x - w/2) + b + 'px',

top: (y - h/2) + a + 'px'

})

}, 30);

},

move: function () {

var aBox = document.querySelectorAll('.box');

var _this = this;

var body = document.body;

var left,top,r,ele,w;

[].slice.call(aBox).forEach(function (e) {

e.addEventListener('click', function () {

ele = _this.cEle('div', 'round');

w = Math.floor(Math.random() * 50 + 10);

left = this.offsetLeft + this.offsetWidth/2;

top = this.offsetTop + this.offsetHeight/2;

r = this.offsetWidth + Math.floor(Math.random() * 50);

_this.css(ele, {

width: w + 'px',

height: w + 'px'

})

body.appendChild(ele);

_this.round(ele, left, top, r);

}, false)

})

}

}

app.init();

總結(jié)

以上是生活随笔為你收集整理的html线条绕圆旋转,js围绕圆旋转的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。