一个好看的标签云js代码,风格类似于windows系统的metro界面样式,看起来挺不错的,蓝叶就花了点时间找到了代码,动动手修改下就可以放你的网站上使用,复制下方代码到新建html文件里,在浏览器打开就能看到如图一样的效果。
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="renderer" content="webkit"> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0"> <title>标签云效果</title> <style> *{margin:0;padding:0;border:0;} .wordbox{position:relative;} .box{position: absolute;text-align: center;word-wrap: break-word;overflow: hidden;border: 1px solid rgb(255 255 255 / 0.6);transition-duration: .6s,.6s;transition-property: background-color,color;transition-timing-function: ease,ease;} .box:hover{ opacity:0.6} .box a {color: #fff;text-decoration: none;display: inline-block;width: 100%;height:100%;} </style> <script type="text/javascript" src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/wordbox@1.3.1/dist/wordbox.min.js"></script> </head> <body> <div id="wordbox"></div> <script type="text/javascript"> var titles = ['JavaScript', 'CSS', 'HTML', 'HTML5', 'SVG', 'PHP', 'Python', 'Shell', 'WebGL']; var words = []; for(var i = 0; i < titles.length; i++) { words[i] = { "title" : titles[i], "url" : "" } } var colors = ['#cc5b34', '#ff9800','#00aff0','#09c','#8bc34a','#136486']; $("#wordbox").wordbox({ isLead: false, leadWord: {'title': '全部', 'url': ''}, words: words, colors: colors, isFixedWidth: true, width: window.innerWidth - 2, height: 160 }); </script> </body> </html>
免责声明:
本页网址:点击复制分享给朋友吧!
本站分享的一切内容资源如若没有备注,均为蓝叶原创,如需转载请注明出处;如有侵权请与我们联系处理。敬请谅解!