JS隨機標籤雲

來源:互聯網
上載者:User

簡單的隨機標籤雲

<!DOCTYPE HTML><html><head><meta charset="UTF-8"><title>隨機標籤雲</title><style type="text/css">*{margin:0;padding:0}a{ text-decoration:none}#wrap{width:400px;margin:auto}</style>  <script type="text/javascript">    window.onload=function(){      var obox=document.getElementById("wrap");      var obj=obox.getElementsByTagName("a");      //隨機方法      function rand(num){       return parseInt(Math.random()*num+1);      }      //隨機顏色值      function randomcolor(){        var str=Math.ceil(Math.random()*16777215).toString(16);        if(str.length<6){          str="0"+str;        }        return str;      }      //迴圈      for( len=obj.length,i=len;i--;){        obj[i].className="color"+rand(5);        obj[i].style.zIndex=rand(5);        obj[i].style.fontSize=rand(12)+12+"px";       // obj[i].style.background="#"+randomcolor();        obj[i].style.color="#"+randomcolor();        obj[i].onmouseover=function(){          this.style.background="#"+randomcolor();        }obj[i].onmouseout=function(){          this.style.background="none";        }      }    }  </script></head><body> <div id="wrap">   <a href="#">web標準學習</a>   <a href="#">css</a>   <a href="#">javascript</a>   <a href="#">html5</a>   <a href="#">canvas</a>   <a href="#">video</a>   <a href="#">audio</a>   <a href="#">jQuery</a>   <a href="#">jQuerymobile</a>   <a href="#">flash</a>   <a href="#">firefox</a>   <a href="#">chrome</a>   <a href="#">opera</a>   <a href="#">IE9</a>   <a href="#">css3.0</a>   <a href="#">andriod</a>   <a href="#">apple</a>   <a href="#">google</a>   <a href="#">jobs</a>  </div></body></html>

這個的演算法較為簡單(偶能看得懂 orz....),但也基本上實現了要求

還有一個類似QQ好友印象的標籤,有疊加效果,具體移步:http://www.xiaoqiang.org/javascript/tag-flag.html

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.