Computer >> कंप्यूटर >  >> प्रोग्रामिंग >> Mongodb

CSS और JavaScript के साथ पूर्ण-पृष्ठ टैब कैसे बनाएं?


सीएसएस और जावास्क्रिप्ट के साथ पूर्ण-पृष्ठ टैब बनाने के लिए, कोड इस प्रकार है -

उदाहरण

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box}
body, html {
   height: 100%;
   margin: 0;
}
.tablink {
   background-color: #555;
   color: white;
   float: left;
   border: none;
   outline: none;
   cursor: pointer;
   padding: 10px 14px;
   font-size: 15px;
   width:33.33%;
}
.tablink:hover {
   background-color: black;
}
.tabcontent {
   color: white;
   display: none;
   padding: 100px 20px;
   height: 100%;
}
#Home {background-color: blue;}
#About {background-color: gray;}
#Contact {background-color: orange;}
</style>
</head>
<body>
<button class="tablink" onclick="demo('Home', this, 'blue')">Home</button>
<button class="tablink" onclick="demo('About', this, 'gray')" id="clickme">About</button>
<button class="tablink" onclick="demo('Contact', this, 'orange')">ContactUs</button>
<div id="Home" class="tabcontent">
   <h3>Home</h3>
   <p>This is the Home page.</p>
</div>
<div id="About" class="tabcontent">
   <h3>About</h3>
   <p>This is information about the company.</p>
</div>
<div id="Contact" class="tabcontent">
   <h3>ContactUs</h3>
   <p>Contact us for any feedback, query and complaints.</p>
</div>
<script>
function demo(pageName,elmnt,color) {
   var i, tabcontent, tablinks;
   tabcontent = document.getElementsByClassName("tabcontent");
   for (i = 0; i < tabcontent.length; i++) {
      tabcontent[i].style.display = "none";
   }
   tablinks = document.getElementsByClassName("tablink");
   for (i = 0; i < tablinks.length; i++) {
      tablinks[i].style.backgroundColor = "";
   }
   document.getElementById(pageName).style.display = "block";
   elmnt.style.backgroundColor = color;
}
document.getElementById("clickme").click();
</script>
</body>
</html>

आउटपुट

यह निम्नलिखित आउटपुट देगा -

CSS और JavaScript के साथ पूर्ण-पृष्ठ टैब कैसे बनाएं?

आइए अब "ContactUs" टैब पर क्लिक करें -

CSS और JavaScript के साथ पूर्ण-पृष्ठ टैब कैसे बनाएं?


  1. CSS और JavaScript के साथ ट्री व्यू कैसे बनाएं?

    सीएसएस और जावास्क्रिप्ट के साथ एक ट्री व्यू बनाने के लिए, कोड इस प्रकार है - उदाहरण <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style>    body {       font-family: &qu

  1. कैसे सीएसएस और जावास्क्रिप्ट के साथ एक उद्धरण स्लाइड शो बनाने के लिए?

    CSS और JavaScript के साथ एक कोट स्लाइड शो बनाने के लिए, कोड इस प्रकार है - उदाहरण <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style>    body {       font-family: "

  1. सीएसएस और जावास्क्रिप्ट के साथ एक विस्तारित ग्रिड कैसे बनाएं?

    सीएसएस और जावास्क्रिप्ट के साथ एक विस्तृत ग्रिड बनाने के लिए, कोड इस प्रकार है - उदाहरण <!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <style>    body {       padding: 1%;