Page transition
How do I make an page transition?
What is a page transition? How do you make a page transition? This script and codes were developed by Pedro Cacique on 20 November 2022, Sunday.
Page transition - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Page transition</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <nav> <button id="nav1"></button> <button id="nav2"></button> <button id="nav3"></button>
</nav>
<section id="page1"></section>
<section id="page2"></section>
<section id="page3"></section> <script src="js/index.js"></script>
</body>
</html>
Page transition - Script Codes CSS Codes
html{ background-color:#fff; height: 100%;
}
body{ background-color: #e8f3e2; height: 100%; margin:0;
}
section{ height: 80%; width: 90%; position:absolute; transition: all 1s;
}
#page1, #nav1{ background-color: #b5d780;
}
#page2,#nav2{ background-color: #fac1c4;
}
#page3, #nav3{ background-color: #c2e4d8;
}
nav{ top:0; margin: 0 auto; width: 200px; text-align: center; padding: 10px;
}
nav button{ border: none; width: 30px; height: 30px; border-radius: 50%; cursor:pointer;
}
nav button:focus{ outline: none;
}
Page transition - Script Codes JS Codes
var pages = [];
var total = 3;
var w, h;
window.onload = function(){ w = document.body.clientWidth; h = document.body.clientHeight; for(var i=1; i<=total; i++){ page = document.getElementById("page"+i); page.style.left = (w/2 - page.offsetWidth/2)+"px"; page.style.top = (h/2 - page.offsetHeight/2)+"px"; page.style.left = -page.offsetWidth+"px"; page.style.zIndex = 1; page.style.opacity = 0; pages.push(page); document.getElementById("nav"+i).addEventListener("click", openPage, true); }
}
function openPage(event){ var num = parseInt(event.target.id.split("nav")[1]); for(var i=0; i<pages.length; i++){ page = pages[i]; page.style.left = -page.offsetWidth+"px"; page.style.zIndex = 1; page.style.opacity = 0; } page = pages[num-1]; page.style.left = (w/2 - page.offsetWidth/2)+"px"; page.style.zIndex = 2; page.style.opacity = 1;
}
Developer | Pedro Cacique |
Username | phcacique |
Uploaded | November 20, 2022 |
Rating | 3 |
Size | 2,127 Kb |
Views | 14,168 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Web Theremin | 3,970 Kb |
Grid Interaction | 3,469 Kb |
One page scrolling | 2,113 Kb |
Aside Hover Menu | 1,938 Kb |
Platform game mechanics | 2,799 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
3D-box | Parthviroja | 2,346 Kb |
SVG Text Masking | JMChristensen | 2,141 Kb |
404 Error Page | WebSonick | 3,203 Kb |
Two Element Typeface | Chrisota | 4,942 Kb |
Flex Chart | James_zedd | 4,111 Kb |
Responsive Pricing Table | Jeremycaris | 2,690 Kb |
03 - CSS Variables | Run-time | 2,682 Kb |
Slide like Mailbox | Hmps | 3,758 Kb |
BSP Dungeon Generation | Xgundam05 | 5,326 Kb |
Super Discount | Orrinward | 3,225 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!