您现在的位置是:网站首页> 编程资料编程资料
一款超酷的js+css3实现的3D标签云特效兼容ie7/8/9CSS3+DIV实现漂亮的动画彩色标签HTML5 SVG和CSS3实现的表单浮动标签特效源码仅6个span标签实现的纯CSS3动态Loading加载特效源码jQuery+ajax+html5+css3等最新技术整合的Tab标签栏切换特效纯css3实现的tab标签(无图片)CSS3的几个标签速记(推荐)
2023-10-26
158人已围观
简介 一款超酷的js+css3实现的3D标签云特效,兼容ie7/8/9,看惯了flash的,来试试这个吧,下面有个不错的示例,希望大家不要错过
今天给大家带来一款超酷的js+css3实现的3D标签云特效,
看惯了flash的,来试试这个吧。
ie7,8,9兼容哦~
html如下:
js代码如下(tagscloud.js):
var radius = 90;
var d = 200;
var dtr = Math.PI / 180;
var mcList = [];
var lasta = 1;
var lastb = 1;
var distr = true;
var tspeed = 11;
var size = 200;
var mouseX = 0;
var mouseY = 10;
var howElliptical = 1;
var aA = null;
var oDiv = null;
window.onload=function ()
{
var i=0;
var oTag=null;
oDiv=document.getElementById('tagscloud');
aA=oDiv.getElementsByTagName('a');
for(i=0;i
oTag={};
aA[i].onmouseover = (function (obj) {
return function () {
obj.on = true;
this.style.zIndex = 9999;
this.style.color = '#fff';
this.style.background = '#0099ff';
this.style.padding = '5px 5px';
this.style.filter = "alpha(opacity=100)";
this.style.opacity = 1;
}
})(oTag)
aA[i].onmouseout = (function (obj) {
return function () {
obj.on = false;
this.style.zIndex = obj.zIndex;
this.style.color = '#fff';
this.style.background = '#9933FF';
this.style.padding = '5px';
this.style.filter = "alpha(opacity=" + 100 * obj.alpha + ")";
this.style.opacity = obj.alpha;
this.style.zIndex = obj.zIndex;
}
})(oTag)
oTag.offsetWidth = aA[i].offsetWidth;
oTag.offsetHeight = aA[i].offsetHeight;
mcList.push(oTag);
}
sineCosine( 0,0,0 );
positionAll();
(function () {
update();
setTimeout(arguments.callee, 40);
})();
};
function update()
{
var a, b, c = 0;
a = (Math.min(Math.max(-mouseY, -size), size) / radius) * tspeed;
b = (-Math.min(Math.max(-mouseX, -size), size) / radius) * tspeed;
lasta = a;
lastb = b;
if (Math.abs(a) <= 0.01 && Math.abs(b) <= 0.01) {
return;
}
sineCosine(a, b, c);
for (var i = 0; i < mcList.length; i++) {
if (mcList[i].on) {
continue;
}
var rx1 = mcList[i].cx;
var ry1 = mcList[i].cy * ca + mcList[i].cz * (-sa);
var rz1 = mcList[i].cy * sa + mcList[i].cz * ca;
var rx2 = rx1 * cb + rz1 * sb;
var ry2 = ry1;
var rz2 = rx1 * (-sb) + rz1 * cb;
var rx3 = rx2 * cc + ry2 * (-sc);
var ry3 = rx2 * sc + ry2 * cc;
var rz3 = rz2;
mcList[i].cx = rx3;
mcList[i].cy = ry3;
mcList[i].cz = rz3;
per = d / (d + rz3);
mcList[i].x = (howElliptical * rx3 * per) - (howElliptical * 2);
mcList[i].y = ry3 * per;
mcList[i].scale = per;
var alpha = per;
alpha = (alpha - 0.6) * (10 / 6);
mcList[i].alpha = alpha * alpha * alpha - 0.2;
mcList[i].zIndex = Math.ceil(100 - Math.floor(mcList[i].cz));
}
doPosition();
}
function depthSort()
{
var i=0;
var aTmp=[];
for(i=0;i
aTmp.push(aA[i]);
}
aTmp.sort
(
function (vItem1, vItem2)
{
if(vItem1.cz>vItem2.cz)
{
return -1;
}
else if(vItem1.cz
return 1;
}
else
{
return 0;
}
}
);
for(i=0;i
aTmp[i].style.zIndex=i;
}
}
function positionAll()
{
var phi = 0;
var theta = 0;
var max = mcList.length;
for (var i = 0; i < max; i++) {
if (distr) {
phi = Math.acos(-1 + (2 * (i + 1) - 1) / max);
theta = Math.sqrt(max * Math.PI) * phi;
} else {
phi = Math.random() * (Math.PI);
theta = Math.random() * (2 * Math.PI);
}
//坐标变换
mcList[i].cx = radius * Math.cos(theta) * Math.sin(phi);
mcList[i].cy = radius * Math.sin(theta) * Math.sin(phi);
mcList[i].cz = radius * Math.cos(phi);
aA[i].style.left = mcList[i].cx + oDiv.offsetWidth / 2 - mcList[i].offsetWidth / 2 + 'px';
aA[i].style.top = mcList[i].cy + oDiv.offsetHeight / 2 - mcList[i].offsetHeight / 2 + 'px';
}
}
function doPosition()
{
var l = oDiv.offsetWidth / 2;
var t = oDiv.offsetHeight / 2;
for (var i = 0; i < mcList.length; i++) {
if (mcList[i].on) {
continue;
}
var aAs = aA[i].style;
if (mcList[i].alpha > 0.1) {
if (aAs.display != '')
aAs.display = '';
} else {
if (aAs.display != 'none')
aAs.display = 'none';
continue;
}
aAs.left = mcList[i].cx + l - mcList[i].offsetWidth / 2 + 'px';
aAs.top = mcList[i].cy + t - mcList[i].offsetHeight / 2 + 'px';
//aAs.fontSize=Math.ceil(12*mcList[i].scale/2)+8+'px';
//aAs.filter="progid:DXImageTransform.Microsoft.Alpha(opacity="+100*mcList[i].alpha+")";
aAs.filter = "alpha(opacity=" + 100 * mcList[i].alpha + ")";
aAs.zIndex = mcList[i].zIndex;
aAs.opacity = mcList[i].alpha;
}
}
function sineCosine( a, b, c)
{
sa = Math.sin(a * dtr);
ca = Math.cos(a * dtr);
sb = Math.sin(b * dtr);
cb = Math.cos(b * dtr);
sc = Math.sin(c * dtr);
cc = Math.cos(c * dtr);
}
相关内容
- float元素浮动后高度不一致导致错位的解决办方法理解CSS浮动float、定位positioncss浮动(float/clear)使用讲解清除浮动(float)的影响介绍
- JS/CSS压缩工具(YUI Compressor)使用方法JS与css 压缩工具 yuicompressor
- css页面中常见左中右分栏布局的两种实现方式用纯CSS实现容器内图片上下左右居中css实现div内图片上下左右居中css页面左中右分栏布局示例详解css布局实现左中右布局的5种方式
- div+css实现圆角即网页上常用的圆角效果设置div背景透明的方法示例CSS实现div不设高度完全居中div自适应高度自动填充剩余高度详解DIV+CSS的命名规矩才能有利于SEO优化的实现方法DIV或者DIV里面的图片水平与垂直居中的方法详解如何用div实现自制滚动条div对齐与网页布局详解DIV+CSS实现电台列表设计的示例代码div+css实现带箭头的面包屑导航栏不定宽高的文字在div中垂直居中实现方法
- 雷霆战机僚机哪个比较好 僚机选择攻略推荐_手机游戏_游戏攻略_
- 雷霆战机装备选择技巧攻略 两大热度僚机_手机游戏_游戏攻略_
- 腾讯雷霆战机辅助修改方法说明 卡箱子BUG_手机游戏_游戏攻略_
- 雷霆战机腾讯破解刷分教程攻略推荐_手机游戏_游戏攻略_
- 腾讯雷霆战机辅助刷分教程攻略 空降无限烈火_手机游戏_游戏攻略_
- 全民飞机大战刷分攻略_最新叉叉助手刷分破百万教程推荐_手机游戏_游戏攻略_
点击排行
本栏推荐
