今天给大家带来一款超酷的js+css3实现的3D标签云特效,
看惯了flash的,来试试这个吧。
ie7,8,9兼容哦~
html如下:
body,ul,li,h1,h2,h3,p,form{margin:0;padding:0;}body{background:#fbfbfb;color:#444;font-size:14px;}</p>
<p>a{color:#444;text-decoration:none;}a:hover{color:red;}</p>
<p>#tagscloud{width:240px;height:250px;position:relative;font-size:12px;color:#333;margin:20px auto 0;text-align:center;}
#tagscloud a{position:absolute;top:0px;left:0px;color:#333;font-family:Arial;text-decoration:none;}
#tagscloud a:hover{color:#fff;padding:5px;display:block;background:#D02F53;}
#tagscloud a.tagc1{margin:0 10px 15px 0;line-height:18px;width:65px;text-align:center;font-size:12px;padding:1px 5px;white-space:nowrap;display:inline-block;border-radius:3px;background:#666;color:#fff;}
#tagscloud a.tagc2{margin:0 10px 15px 0;line-height:18px;width:60px;text-align:center;font-size:12px;padding:1px 5px;white-space:nowrap;display:inline-block;border-radius:3px;background:#F16E50;color:#fff;}
#tagscloud a.tagc5{margin:0 10px 15px 0;line-height:18px;width:70px;text-align:center;font-size:12px;padding:1px 5px;white-space:nowrap;display:inline-block;border-radius:3px;background:#006633;color:#fff;}
</style>
</head>
<body>
<center>
<div style="font-size:15px; font-weight:bold; text-align:center; line-height:25px;">超酷的js+css3实现的3D标签云特效
</center>
<div id="tagscloud">
<a href="#" class="tagc1" title="星级评分">星级评分(2)</a>
<a href="#" class="tagc2" title="层特效">层特效(34)</a>
<a href="#" class="tagc5" title="关键字">关键字(8)</a>
<a href="#" class="tagc2" title="拖拽">拖拽(5)</a>
<a href="#"" class="tagc2" title="分页插件">分页插件(6)</a>
<a href="#" class="tagc1" title="时间插件">时间插件(9)</a>
<a href="#" class="tagc2" title="弹出层">弹出层(60)</a>
<a href="#" class="tagc5" title="数据统计">数据统计(2)</a>
<a href="#" class="tagc2" title="HTML5">HTML5(12)</a>
<a href="#" class="tagc2" title="置顶特效">置顶特效(5)</a>
<a href="#" class="tagc5" title="选项卡">选项卡(23)</a>
<a href="#" class="tagc2" title="导航菜单">导航菜单(31)</a>
<a href="#" class="tagc1" title="原创作品">原创作品(3)</a>
<a href="#" class="tagc2" title="动画插件">动画插件(15)</a>
<a href="#" class="tagc5" title="实用特效">实用特效(47)</a>
<a href="#" class="tagc2" title="table插件">table插件(1)</a>
<a href="#" class="tagc2" title="文字特效">文字特效(20)</a>
<a href="#" class="tagc5" title="图片特效">图片特效(61)</a>
<a href="#" class="tagc1" title="在线客服">在线客服(4)</a>
<a href="#" class="tagc2" title="瀑布流">瀑布流(10)</a>
<a href="#" class="tagc5" title="网友蘑菇">网友蘑菇(0)</a>
<a href="#" class="tagc2" title="网友嘿嘿">网友嘿嘿(3)</a>
<a href="#" class="tagc2" title="前端工具">前端工具(4)</a>
<a href="#" class="tagc2" title="网友Adam">网友Adam(15)</a>
<a href="#" class="tagc1" title="三级联动">三级联动(21)</a>
<a href="#" class="tagc2" title="颜色插件">颜色插件(4)</a>
<a href="#" class="tagc5" title="向导特效">向导特效(2)</a>
<a href="#" class="tagc2" title="自动补全">自动补全(5)</a>
<a href="#" class="tagc1" title="滚动特效">滚动特效(22)</a>
<a href="#" class="tagc5" title="提示插件">提示插件(24)</a>
</div></p>
<p><script src='tagscloud.js' language='javascript'></script>
</body>
</html>
js代码如下(tagscloud.js):
var rz1 = mcList[i].cy * sa + mcList[i].cz * ca;</p>
<p>var rx2 = rx1 * cb + rz1 * sb;
var ry2 = ry1;
var rz2 = rx1 * (-sb) + rz1 * cb;</p>
<p>var rx3 = rx2 * cc + ry2 * (-sc);
var ry3 = rx2 * sc + ry2 * cc;
var rz3 = rz2;</p>
<p>mcList[i].cx = rx3;
mcList[i].cy = ry3;
mcList[i].cz = rz3;</p>
<p>per = d / (d + rz3);</p>
<p>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<aA.length;i++)
{
aTmp.push(aA[i]);
}
aTmp.sort
(
function (vItem1, vItem2)
{
if(vItem1.cz>vItem2.cz)
{
return -1;
}
else if(v