Navigation Tabs

Size
3,053 Kb
Views
32,384

How do I make an navigation tabs?

What is a navigation tabs? How do you make a navigation tabs? This script and codes were developed by Mobile Application Design-Development on 10 August 2022, Wednesday.

Navigation Tabs Previews

Navigation Tabs - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Navigation Tabs</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div data-role="header"> <a href="#" data-role="pagelink" data-rel="back">&laquo;Back</a> <h1>Page Title</h1>
</div>
<div data-role="page" id="home"> <ul class="tabs"> <li class="tab"><a href="#home" data-role="pagelink" class="active">Home</a></li> <li class="tab"><a href="#stuff" data-role="pagelink" class="">Stuff</a></li> </ul> <div data-role="content"> <h3>Info</h3> <p>Some content on the home page.</p> <p>Some content on the home page.</p> <p>Some content on the home page.</p> <p>Some content on the home page.</p> <p>Some content on the home page.</p> </div>
</div>
<div data-role="page" id="stuff"> <ul class="tabs"> <li class="tab"><a href="#home" data-role="pagelink" class="">Home</a></li> <li class="tab"><a href="#stuff" data-role="pagelink" class="active">Stuff</a></li> </ul> <div data-role="content"> <h3>Info</h3> <p>Some content on the stuff page.</p> <p>Some content on the stuff page.</p> <p>Some content on the stuff page.</p> <p>Some content on the stuff page.</p> <p>Some content on the stuff page.</p> <p>Some content on the stuff page.</p> </div>
</div> <script src="js/index.js"></script>
</body>
</html>

Navigation Tabs - Script Codes CSS Codes

*{	padding:0;	margin:0; box-sizing: border-box;
}
html{	width:100%;	height:100%; background-color:#333; font-family: Calibri, Arial, Helvetica, sans-serif;
}
h2, h3, p{	padding:0.2rem 2rem;
}
/* ******************************* TABS
******************************* */
ul.tabs{	width:100%;	min-height:3rem; list-style:none; overflow:auto;
}
.tabs li.tab{	background-color:#444;	float:left;	width:50%;
}
.tabs li.tab a{	display: block;	padding: 0.5rem 2rem;	font-size: 2rem;	line-height: 2rem;	color: #fff;	text-decoration: none;	border: none;	background-color: #555;	text-align: center;
}
.tabs li.tab a.active{	background-color:#333; /* to match the active page */	border-top:1px solid #666;	border-right:1px solid #222;	border-left:1px solid #666;
}
/* ******************************* PAGES
******************************* */
[data-role="page"]{	display:none;	background-color:#333;	color: #bbb;	width:100%;
}
[data-role="header"]{	background-color:#111; position:relative; /* for the back button */
}
[data-role="header"] h1{ text-shadow: 1px 1px 1px #0cf; padding:0.4rem; color:#d4d4d4; text-align:center; letter-spacing:0.3rem; word-spacing: 1rem; font-variant:small-caps;
}
[data-role="content"]{ margin-top: -1px;	border-top:1px solid #666; /* to match the top of the active tab */
}
[data-role="content"] p:last-child{	padding-bottom:4rem;
}
[data-rel="back"]{	position:absolute; /* prevents the h1 from moving */ z-index: 10;	color:#fff;	padding:0.3rem 1rem; color: #0C3; font-size: 1rem; line-height:2.0rem; text-decoration:none; display:none;
}

Navigation Tabs - Script Codes JS Codes

// JavaScript Document
var pages = [];
var numLinks = 0;
var numPages = 0;
document.addEventListener("DOMContentLoaded", function(){	//device ready listener	pages = document.querySelectorAll('[data-role="page"]');	numPages = pages.length;	var links = document.querySelectorAll('[data-role="pagelink"]');	numLinks = links.length;	for(var i=0;i<numLinks; i++){	links[i].addEventListener("click", handleNav, false);	} location.hash = "#"; //for demo purposes to reset the page window.addEventListener("hashchange", loadPage); location.hash = "#home";	history.replaceState(null, null, "#home");
});
function handleNav(ev){	ev.preventDefault();	var href = ev.target.href;	var parts = href.split("#"); location.hash = "#"+parts[1]; //console.log("handleNav - ", parts[1] ); return false;
}
function loadPage ( ev ) { var url = location.hash; //console.log("newURL", ev.newURL); //console.log("oldURL", ev.oldURL); //show | hide the back button if( url !== "#home"){ document.querySelector('[data-rel="back"]').style.display = "block"; }else{ document.querySelector('[data-rel="back"]').style.display = "none"; } //loop through pages and show the one that matches the hash for (var i=0; i < numPages; i++) { if ( ("#" + pages[i].id) === url) { pages[i].style.display = "block"; //add the new page to the history array history.pushState(null, null, url); } else { pages[i].style.display = "none"; } }
}
//Still need a listener for the popstate event to handle the back button
//Still need a listener for the back button in the header
Navigation Tabs - Script Codes
Navigation Tabs - Script Codes
Home Page Home
Developer Mobile Application Design-Development
Username mad-d
Uploaded August 10, 2022
Rating 3
Size 3,053 Kb
Views 32,384
Do you need developer help for Navigation Tabs?

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!

Mobile Application Design-Development (mad-d) Script Codes
Create amazing web content with AI!

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!