使用jQuery制作3d标签云教程

渲染JavaScript的浏览器,比以往更快例如firefox,ie不提了,发挥jQuery 创意。此教程将展示如何创建一个滚动的3d标签云.
我们先来看下css
body{
font-family: Arial, "MS Trebuchet", sans-serif;
background-color: #111;
}
#list{
margin:0 auto;
height:600px;
width:600px;
overflow:hidden;
position:relative;
background-color: #000;
}
#list ul,
#list li{
list-style:none;
margin:0;
padding:0;
}
#list a{
position:absolute;
text-decoration: none;
color:#666;
}
#list a:hover{
color:#ccc;
} html代码:


  • ajax

  • css

  • design

  • firefox

  • flash

  • html

  • Devirtuoso

  • jquery

  • PHP

  • SEO

  • usability

  • www

  • web

  • xhtml



javascript代码:
$(document).ready(function(){

var element = $('#list a'); ;
var offset = 0;
var stepping = 0.03;
var list = $('#list');
var $list = $(list)

$list.mousemove(function(e){
var topOfList = $list.eq(0).offset().top
var listHeight = $list.height()
stepping = (e.clientY - topOfList) /listHeight * 0.2 - 0.1;

});
for (var i = element.length - 1; i >= 0; i--)
{
element[i].elemAngle = i * Math.PI * 2 / element.length;
}


setInterval(render, 20);


function render(){
for (var i = element.length - 1; i >= 0; i--){

var angle = element[i].elemAngle + offset;

x = 120 + Math.sin(angle) * 30;
y = 45 + Math.cos(angle) * 40;
size = Math.round(40 - Math.sin(angle) * 40);

var elementCenter = $(element[i]).width() / 2;

var leftValue = https://www.it610.com/article/(($list.width()/2) * x / 100 - elementCenter) +"px"

$(element[i]).css("fontSize", size + "pt");
$(element[i]).css("opacity",size/100);
$(element[i]).css("zIndex" ,size);
$(element[i]).css("left" ,leftValue);
$(element[i]).css("top", y + "%");
}

offset += stepping;
}


}); 注意还要加上jq库
【使用jQuery制作3d标签云教程】

    推荐阅读