css中的嵌套怎么写,CSS3 嵌套圆圈

JavaScript

语言:

JaveScriptBabelCoffeeScript

确定

function Dot(settings) {

var defaults = {

dots: 10,

dotSize: 10,

dotColor: 'black',

radius: 200,

spacing: 0

}

this.config = $.extend({}, defaults, settings);

this.init();

};

Dot.prototype.init = function() {

this.createDot();

};

Dot.prototype.createDot = function() {

var wh = $(window).height();

var ww = $(window).width();

var hwh = wh * .5;

var hww = ww * .5;

var counter = 0;

var dots = this.config.dots;

var dotSize = this.config.dotSize;

var radius = this.config.radius;

var PI = Math.PI;

var dotCount = 1;

var rowCount = 1;

// um... there has to be a less complicated way to do this

var increase = PI * 2 / (dots - Math.ceil( ( (dots * dotSize) - (2 * PI * radius) ) / dotSize) );

// var increase = Math.PI * 2 / this.config.dots;

for (var i = 0; i < dots; i++) {

var dot = document.createElement('span');

if ( dotCount * dotSize > 2 * PI * radius) {

radius += dotSize * 2;

dotCount = 1;

increase = PI * 2 / (dots - Math.ceil( ( (dots * dotSize) - (2 * PI * radius) ) / dotSize) );

rowCount++;

}

x = Math.cos(counter) * radius;

y = Math.sin(counter) * radius;

//style stuff

dot.style.left = x + hww - (dotSize * .5) + 'px';

dot.style.top = y + hwh - (dotSize * .5) + 'px';

dot.style.height = dotSize + 'px';

dot.style.width = dotSize + 'px';

dot.style.borderRadius = '50%';

dot.style.position = 'absolute';

dot.style.display = 'none';

dot.style.backgroundColor = this.config.dotColor;

dot.className = 'row-' + rowCount;

document.body.appendChild(dot);

counter += increase;

dotCount++;

};

};

//--------------

var dot = new Dot({

dots: 1750, // span elements

dotSize: 25, // in pixels

dotColor: 'tomato',

radius: 20, // in pixels

spacing: 5 // in pixels

});

for (var i = 0; i < 50; i++) {

$('.row-' + i).velocity(

'transition.expandIn',

{

delay: 50 * i,

duration: 100

});

};

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值