今天在微博里面看到别人分享的一个立体效果,我觉得挺好的,就拿下来自己存着,万一以后用到。
效果如下:
index.html
CSS3 3D立方体菜单导航DEMO演示
index2.html
CSS3 3D立方体菜单导航DEMO演示
js文件:
index.js
// // Inspired by JTK-Developments// ----// https://codepen.io/jtkDvlp/pen/lswmu//$(".side").on("click", "li", function(){ $("#cube").removeClass().addClass($(this).attr("class"));}).on("mouseover", "li", function(){ var me = $(this); var attr = me.attr("data-url"); if(attr != undefined){ $("h2").text(attr).css("visibility", "visible"); }});
css文件:
style.css
body { position: absolute; top: 0; right: 0; bottom: 0; left: 0; background-color: #E7EAE3; -moz-box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.4); -webkit-box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.4); box-shadow: inset 0 0 100px rgba(0, 0, 0, 0.4);}ul { list-style: none; margin: 0; padding: 0;}p { line-height: 22px; position: absolute; left: 0; font-size: 12px; right: 0; color: rgba(255, 255, 255, 0.5); font-style: italic; cursor: default;}nav { height: 240px; width: 240px; position: absolute; left: 0; right: 0; top: 0; bottom: 0; margin: auto; perspective: 1000px; -webkit-perspective: 1000px; -moz-perspective: 1000px;}h2 { color: #9EA7B3; font-weight: normal; font-style: italic; text-align: center; font-size: 18px; margin-top: -40px; visibility: hidden; -moz-transition: all 0.4s ease; -o-transition: all 0.4s ease; -webkit-transition: all 0.4s ease; transition: all 0.4s ease;}h3 { color: rgba(255, 255, 255, 0.3) !important; cursor: default; font-weight: normal; margin: 0; line-height: 42px; font-size: 14px;}.side { color: white; background-color: #2C2C2C; -moz-border-radius: 10px; -webkit-border-radius: 10px; border-radius: 10px; -moz-box-shadow: 0 0 6px rgba(0, 0, 0, 0.5); -webkit-box-shadow: 0 0 6px rgba(0, 0, 0, 0.5); box-shadow: 0 0 6px rgba(0, 0, 0, 0.5);}.side span { font-size: 12px; position: relative; top: -36px; color: rgba(255, 255, 255, 0.3); opacity: 0; -moz-transition: opacity 0.4s ease; -o-transition: opacity 0.4s ease; -webkit-transition: opacity 0.4s ease; transition: opacity 0.4s ease;}.side li { width: 50px; height: 50px; float: left; margin-left: 22px; margin-top: 20px; text-align: center; line-height: 60px; -moz-transition: color 0.4s ease; -o-transition: color 0.4s ease; -webkit-transition: color 0.4s ease; transition: color 0.4s ease;}.side li:hover { color: #FD6347;}.side li:hover span { opacity: 1;}.round { color: rgba(255, 255, 255, 0.3); font-size: 22px; line-height: 26px; padding: 4px; width: 28px; height: 28px; position: relative; top: -6px; display: inline-block; background-color: rgba(255, 255, 255, 0.1); -moz-border-radius: 50%; -webkit-border-radius: 50%; border-radius: 50%;}#cube { position: absolute; height: 100%; width: 100%; transform-style: preserve-3d; -webkit-transform-style: preserve-3d; -moz-transform-style: preserve-3d; -moz-transform: translateZ(-120px); -ms-transform: translateZ(-120px); -webkit-transform: translateZ(-120px); transform: translateZ(-120px); -moz-transition: -moz-transform 0.6s cubic-bezier(0.11, 0.93, 0.65, 0.92); -o-transition: -o-transform 0.6s cubic-bezier(0.11, 0.93, 0.65, 0.92); -webkit-transition: -webkit-transform 0.6s cubic-bezier(0.11, 0.93, 0.65, 0.92); transition: transform 0.6s cubic-bezier(0.11, 0.93, 0.65, 0.92);}.side { position: absolute; top: 0; right: 0; bottom: 0; left: 0;}.icon-dribbble.icon-5x { color: #CB376F;}.icon-4x { color: #DC5C8B !important;}.side:nth-child(6n+1) { -moz-transform: rotateY(0deg) translateZ(120px); -ms-transform: rotateY(0deg) translateZ(120px); -webkit-transform: rotateY(0deg) translateZ(120px); transform: rotateY(0deg) translateZ(120px);}.side:nth-child(6n+2) { -moz-transform: rotateY(90deg) translateZ(120px); -ms-transform: rotateY(90deg) translateZ(120px); -webkit-transform: rotateY(90deg) translateZ(120px); transform: rotateY(90deg) translateZ(120px);}.side:nth-child(6n+3) { -moz-transform: rotateX(180deg) translateZ(120px); -ms-transform: rotateX(180deg) translateZ(120px); -webkit-transform: rotateX(180deg) translateZ(120px); transform: rotateX(180deg) translateZ(120px);}.side:nth-child(6n+4) { -moz-transform: rotateY(-90deg) translateZ(120px); -ms-transform: rotateY(-90deg) translateZ(120px); -webkit-transform: rotateY(-90deg) translateZ(120px); transform: rotateY(-90deg) translateZ(120px);}.side:nth-child(6n+5) { -moz-transform: rotateX(-90deg) translateZ(120px); -ms-transform: rotateX(-90deg) translateZ(120px); -webkit-transform: rotateX(-90deg) translateZ(120px); transform: rotateX(-90deg) translateZ(120px);}.side:nth-child(6n+6) { -moz-transform: rotateX(90deg) translateZ(120px); -ms-transform: rotateX(90deg) translateZ(120px); -webkit-transform: rotateX(90deg) translateZ(120px); transform: rotateX(90deg) translateZ(120px);}#cube.home { -moz-transform: translateZ(-120px) rotateY(0deg); -ms-transform: translateZ(-120px) rotateY(0deg); -webkit-transform: translateZ(-120px) rotateY(0deg); transform: translateZ(-120px) rotateY(0deg);}#cube.about { -moz-transform: translateZ(-120px) rotateY(90deg); -ms-transform: translateZ(-120px) rotateY(90deg); -webkit-transform: translateZ(-120px) rotateY(90deg); transform: translateZ(-120px) rotateY(90deg);}#cube.misc { -moz-transform: translateZ(-120px) rotateX(180deg); -ms-transform: translateZ(-120px) rotateX(180deg); -webkit-transform: translateZ(-120px) rotateX(180deg); transform: translateZ(-120px) rotateX(180deg);}#cube.social { -moz-transform: translateZ(-120px) rotateX(-90deg); -ms-transform: translateZ(-120px) rotateX(-90deg); -webkit-transform: translateZ(-120px) rotateX(-90deg); transform: translateZ(-120px) rotateX(-90deg);}#cube.shop { -moz-transform: translateZ(-120px) rotateY(-90deg); -ms-transform: translateZ(-120px) rotateY(-90deg); -webkit-transform: translateZ(-120px) rotateY(-90deg); transform: translateZ(-120px) rotateY(-90deg);}#cube.dribbble { -moz-transform: translateZ(-120px) rotateX(90deg); -ms-transform: translateZ(-120px) rotateX(90deg); -webkit-transform: translateZ(-120px) rotateX(90deg); transform: translateZ(-120px) rotateX(90deg);}
normalize.min.css
button,hr,input{ overflow:visible}audio,canvas,progress,video{ display:inline-block}progress,sub,sup{ vertical-align:baseline}html{ font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{ margin:0} menu,article,aside,details,footer,header,nav,section{ display:block}h1{ font-size:2em;margin:.67em 0}figcaption,figure,main{ display:block}figure{ margin:1em 40px}hr{ box-sizing:content-box;height:0}code,kbd,pre,samp{ font-family:monospace,monospace;font-size:1em}a{ background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{ outline-width:0}abbr[title]{ border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{ font-weight:bolder}dfn{ font-style:italic}mark{ background-color:#ff0;color:#000}small{ font-size:80%}sub,sup{ font-size:75%;line-height:0;position:relative}sub{ bottom:-.25em}sup{ top:-.5em}audio:not([controls]){ display:none;height:0}img{ border-style:none}svg:not(:root){ overflow:hidden}button,input,optgroup,select,textarea{ font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,input{}button,select{ text-transform:none}[type=submit], [type=reset],button,html [type=button]{ -webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{ border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{ outline:ButtonText dotted 1px}fieldset{ border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{ box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{}textarea{ overflow:auto}[type=checkbox],[type=radio]{ box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{ height:auto}[type=search]{ -webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{ -webkit-appearance:none}::-webkit-file-upload-button{ -webkit-appearance:button;font:inherit}summary{ display:list-item}[hidden],template{ display:none}/*# sourceMappingURL=normalize.min.css.map */