[Application][js css3]3D box navigation[PC]_html/css_WEB-ITnose
Jun 24, 2016 am 11:47 AM
Navigation application of 3D box built with CSS3
1. Place an iframe on the surface of the box built with CSS3 to load the navigation page.
2. Press the left mouse button to move the rotating box and find the desired URL.
3. Left-click on the stand-alone box surface, and the website on the clicked box surface will be displayed in full screen [in an iframe] and can be browsed. After closing, it will return to the original state.
4. On the PC side, two additional rotating boxes made of CSS3 will be displayed [no sense]
5. On the mobile side, only one navigation box will be displayed [The simulator is normal, the real machine Invalid, leave it for future review, and compatibility development needs to be improved. . . ]
Note: I originally planned to arrange the navigation boxes so that the navigation would become more fun
However, if Iframe is used to display the website preview Otherwise, the speed is too slow and consumes too much memory
I tried using html2canvas, but due to cross-domain issues, it was directly destroyed
Solution: The server returns a more real-time preview of the website
---
Executable code download address
http://download.csdn.net /detail/wangxsh42/8522151
---
Rendering
PC version:
Online:
http://wangxinsheng.herokuapp.com/3dboxHome
Code snippet:
1.css3 box build:
html:
1 <div class="cubeOut" style="left:25%;top:35%"> 2 <div class='cube move'> 3 <div class='face'><iframe scrolling="no" loaded="0" url=""></iframe><div class="label"></div><div class="over"></div></div> 4 <div class='face'><iframe scrolling="no" loaded="0" url=""></iframe><div class="label"></div><div class="over"></div></div> 5 <div class='face'><iframe scrolling="no" loaded="0" url=""></iframe><div class="label"></div><div class="over"></div></div> 6 <div class='face'><iframe scrolling="no" loaded="0" url=""></iframe><div class="label"></div><div class="over"></div></div> 7 <div class='face'><iframe scrolling="no" loaded="0" url=""></iframe><div class="label"></div><div class="over"></div></div> 8 <div class='face'><iframe scrolling="no" loaded="0" url=""></iframe><div class="label"></div><div class="over"></div></div> 9 </div>10 </div>
css3:
1 .cubeOut{ 2 height: 100%; 3 left: 50%; 4 margin-left: -10em; 5 margin-top: -10em; 6 -webkit-perspective: 1000px; 7 -ms-perspective: 1000px; 8 perspective: 1000px; 9 position: absolute;10 top: 50%;11 width: 100%;12 }13 .cube {14 height: 100%;15 position: absolute;16 -webkit-transform-style: preserve-3d;17 -ms-transform-style: preserve-3d;18 transform-style: preserve-3d;19 width: 100%;20 transform: rotateX(-35deg) rotateY(35deg);21 }22 .cubeOut .move{ -webkit-animation: 6s spin linear infinite;23 animation: 6s spin linear infinite;}24 .cube * {25 border: 2px solid rgba(54, 226, 248, 0.5);26 display: block;27 height: 100%;28 position: absolute;29 width: 100%;30 }31 .face {32 cursor:pointer;33 height: 100%;34 position: absolute;35 width: 100%;36 }37 .face:nth-child(1) {38 transform: rotateY(0deg) translateZ(150px);39 background: rgba(255, 102, 102, 0.75);40 }41 .face:nth-child(2) {42 transform: rotateY(90deg) translateZ(150px);43 background: rgba(179, 255, 102, 0.75);44 }45 .face:nth-child(3) {46 transform: rotateY(180deg) translateZ(150px);47 background: rgba(102, 255, 255, 0.75);48 }49 .face:nth-child(4) {50 transform: rotateY(270deg) translateZ(150px);51 background: rgba(178, 102, 255, 0.75);52 }53 .face:nth-child(5) {54 transform: rotateX(90deg) translateZ(150px);55 background: rgba(178, 102, 255, 0.75);56 }57 .face:nth-child(6) {58 transform: rotateX(-90deg) translateZ(150px);59 background: rgba(178, 102, 255, 0.75);60 }61 @keyframes spin {62 from {63 -webkit-transform: translateZ(-10em) rotateX(0) rotateY(0deg);64 transform: translateZ(-10em) rotateX(0) rotateY(0deg);65 }66 67 to {68 -webkit-transform: translateZ(-10em) rotateX(360deg) rotateY(360deg);69 transform: translateZ(-10em) rotateX(360deg) rotateY(360deg);70 }71 }72 @-webkit-keyframes spin {73 from {74 -webkit-transform: translateZ(-10em) rotateX(0) rotateY(0deg);75 transform: translateZ(-10em) rotateX(0) rotateY(0deg);76 }77 78 to {79 -webkit-transform: translateZ(-10em) rotateX(360deg) rotateY(360deg);80 transform: translateZ(-10em) rotateX(360deg) rotateY(360deg);81 }82 }
2.js operation code
iframe loading operation [Scale iframe size, visit website with 1024 width by default]
1 $(".cube").find("iframe").each(function(i){ 2 if(this.attributes.url.value!=''){ 3 this.style.height = 1024+"px"; 4 this.style.width = 1024+"px"; 5 this.onload = this.onreadystatechange = iframeload; 6 this.src = this.attributes.url.value;} 7 }); 8 9 function iframeload() { 10 if(outFrame===this){return;}11 if (!this.readyState || this.readyState == "complete") {12 this.focus();13 this.style.transformOrigin = "left top";14 this.style.transform = "scale("+targetWidth/1024+")";15 this.style.display="block";16 $(this).attr("loaded","1");17 }18 }
Box rotation operation
1 var overs = document.querySelectorAll(".fix .over"); 2 for(var i =0;i<overs.length;i++){ 3 if($(overs[i]).prev().prev().attr("url")!='') 4 overs[i].addEventListener("click", mouseclick, false); 5 overs[i].addEventListener("mousedown", mousedown, false); 6 document.addEventListener("mouseup", mouseup, false); 7 overs[i].addEventListener("mousemove", mousemove, false); 8 } 9 10 function mousedown(e){11 mouse.x=e.pageX;12 mouse.y=e.pageY;13 canmove = true;14 }15 function mouseup(e){16 mouse.x=null;17 mouse.y=null;18 canmove = false;19 }20 function mousemove(e){21 if(canmove && mouse.x!=null && mouse.y!=null){22 var ydeg=0,xdeg=0;23 xdeg = e.touches[0].pageX - mouse.x;24 ydeg = e.touches[0].pageY - mouse.y;25 xd = (xd + xdeg)%360;26 yd = (yd -ydeg)%360;27 e.touches[0].target.parentNode.parentNode.style.transform = "rotateX("+yd+"deg) rotateY("+xd+"deg)";28 mouse.x=e.touches[0].pageX;29 mouse.y=e.touches[0].pageY;31 }32 }
Box click operation
1 function mouseclick(e){ 2 var index = $(e.target.parentNode.parentNode.parentNode).find(".over").index($(e.target)); 3 switch(index){ 4 case 0: 5 xd = 0; 6 yd = 0; 7 break; 8 case 1: 9 xd = -270;10 yd = 0;11 break;12 case 2:13 xd = -180;14 yd = 0;15 break;16 case 3:17 xd = -90;18 yd = 0;19 break;20 case 4:21 xd = 0;22 yd = -90;23 break;24 case 5:25 xd = 0;26 yd = 90;27 break;28 default:;29 }30 outFrame = e.target.parentNode.parentNode.getElementsByTagName("iframe")[index];31 32 if($(outFrame).attr("loaded")=="0")33 return;34 35 $(e.target).unbind();36 mouse.x=null;37 mouse.y=null;38 canmove = false;39 e.target.parentNode.parentNode.parentNode.style.zIndex="1000";40 $("#grayDiv").remove();41 $("body").append("<div id='grayDiv' style='position:absolute;left:0px;top:0px;background-color:rgba(0,0,0,0.8);z-index:999;width:"+window.innerWidth+"px;height:"+window.innerHeight+"px;'></div>");42 43 e.target.parentNode.parentNode.style.transform = "rotateX("+yd+"deg) rotateY("+xd+"deg)";44 $(outFrame).attr("loaded","0");45 outFace = $(e.target).prev();46 $(outFrame).appendTo("#grayDiv");47 $(outFrame).attr("scrolling","auto");48 outFrame.style.transform = "scale("+1+")";49 $(outFrame).css("height",window.innerHeight+"px");50 $(outFrame).css("width",window.innerWidth+"px");51 e.target.parentNode.parentNode.parentNode.style.zIndex="2";52 $("<div id='close' style='position:absolute;left:0;top:0;'>關(guān)閉</div>").appendTo("#grayDiv");53 $("#close").click(function(e){54 $(outFrame).insertBefore(outFace);55 $(outFrame).attr("scrolling","no");56 outFrame.style.transform = "scale("+targetWidth/1024+")";57 $(outFrame).css("height",1024+"px");58 $(outFrame).css("width",1024+"px");59 outFrame = null;60 outFace = null;61 $("#grayDiv").remove();62 });63 }
---
css3 3D box code reference:
http://www.html5tricks.com/ html5-animated-cube.html
http://www.html5tricks.com/html5-3d-cube.html
---
chrome mobile emulator Effect [The real machine is currently invalid, leave it to be checked later]:

Hot AI Tools

Undress AI Tool
Undress images for free

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

ARIA's role attribute is used to define the role of web elements and improve accessibility. 1. Role attribute helps assistive technology to understand the functions of elements, such as buttons, navigation, etc. 2. Use role attributes to assign specific roles to non-semantic HTML elements. 3. The role attribute should be consistent with the element behavior and be verified by the accessibility tool test.

How to create a website layout? 1. Use HTML tags to define the content structure, such as, ,. 2. Control styles and positions through CSS, using box model, float or Flexbox layout. 3. Optimize performance, reduce HTTP requests, use cache and optimize images, and ensure responsive design.

Improve the readability and maintainability of HTML code can be achieved through the following steps: 1. Use semantic tags, such as, etc. to make the code structure clear and improve SEO effect; 2. Keep the code formatted and use consistent indentation and spaces; 3. Add appropriate comments to explain the code intention; 4. Avoid excessive nesting and simplify the structure; 5. Use external style sheets and scripts to keep the HTML concise.

The key to keep up with HTML standards and best practices is to do it intentionally rather than follow it blindly. First, follow the summary or update logs of official sources such as WHATWG and W3C, understand new tags (such as) and attributes, and use them as references to solve difficult problems; second, subscribe to trusted web development newsletters and blogs, spend 10-15 minutes a week to browse updates, focus on actual use cases rather than just collecting articles; second, use developer tools and linters such as HTMLHint to optimize the code structure through instant feedback; finally, interact with the developer community, share experiences and learn other people's practical skills, so as to continuously improve HTML skills.

The reason for using tags is to improve the semantic structure and accessibility of web pages, make it easier for screen readers and search engines to understand page content, and allow users to quickly jump to core content. Here are the key points: 1. Each page should contain only one element; 2. It should not include content that is repeated across pages (such as sidebars or footers); 3. It can be used in conjunction with ARIA properties to enhance accessibility. Usually located after and before, it is used to wrap unique page content, such as articles, forms or product details, and should be avoided in, or in; to improve accessibility, aria-labeledby or aria-label can be used to clearly identify parts.

To create a basic HTML document, you first need to understand its basic structure and write code in a standard format. 1. Use the declaration document type at the beginning; 2. Use the tag to wrap the entire content; 3. Include and two main parts in it, which are used to store metadata such as titles, style sheet links, etc., and include user-visible content such as titles, paragraphs, pictures and links; 4. Save the file in .html format and open the viewing effect in the browser; 5. Then you can gradually add more elements to enrich the page content. Follow these steps to quickly build a basic web page.

To create an HTML checkbox, use the type attribute to set the element of the checkbox. 1. The basic structure includes id, name and label tags to ensure that clicking text can switch options; 2. Multiple related check boxes should use the same name but different values, and wrap them with fieldset to improve accessibility; 3. Hide native controls when customizing styles and use CSS to design alternative elements while maintaining the complete functions; 4. Ensure availability, pair labels, support keyboard navigation, and avoid relying on only visual prompts. The above steps can help developers correctly implement checkbox components that have both functional and aesthetics.

HTMLtagsareessentialforstructuringwebpages.Theydefinecontentandlayoutusinganglebrackets,ofteninpairslikeand,withsomebeingself-closinglike.HTMLtagsarecrucialforcreatingstructured,accessible,andSEO-friendlywebpages.
