js悬浮实现分形动画效果代码
代码语言:html
所属分类:悬停
代码描述:js悬浮实现分形动画效果代码
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <style> body { background: #000000 } div { border: 1px solid #FFFFFF; position: absolute; box-sizing: border-box; -moz-box-sizing: border-box; background-color: #000000; opacity: 0.8; -webkit-transition: top 0.5s, left 0.5s, opacity 0.3s; -moz-transition: top 0.5s, left 0.5s, opacity 0.3s; -o-transition: top 0.5s, left 0.5s, opacity 0.3s; transition: top 0.5s, left 0.5s, opacity 0.3s; } div:hover { opacity: 1 } #main { width: 260px; height: 260px; left: 50%; top: 50%; margin-left: -130px; margin-top: -130px; cursor: pointer } </style> </head> <body > <div id="main" onclick="Fractals(this)"></div> <script > ///PARAMETERS //You can try messing with these but take care when increasing LEVELS and CHILDREN values ; a too big amount of generated elements will result in some serious slowdown and can eventually mess with the CSS transitions' display. var LEVELS = 6; var CHILDREN = 3; var SHRINK_FACTOR = 1.7; //RECURSIVELY GENERATE NESTED DIVS function appendFractals(elem) { if (typeof elem.fractal_level == "undefined") { elem.fractal_level = LEVELS; } else { if (elem.fractal_level <= 0) { return false; } } elem.fractal_level--; var e_W = elem.offsetWidth; var e_H = elem.offsetHeight; var children = 0; while (children < CHILDREN) { var ch = document.createElement('div'); ch.style.width = (e_W / SHRINK_FACTOR) + "px"; ch.style.height = (e_H / SHRINK_FACTOR) + "px"; ch.style.marginLeft = "-" + ((e_W / SHRINK_FACTOR) / 2) + "px"; ch.style.marginTop = "-" + ((e_H .........完整代码请登录后点击上方下载按钮下载查看
网友评论0