Responsive Multi-tab Card Design using HTML, CSS & JavaScript

Responsive Multi-tab Card Design using HTML, CSS & JavaScript

Hello developers, today in this blog you’ll learn to create a Responsive Multi-tab Card Design using HTML, CSS & JavaScript.


Multi-tab is a great way to present the content to the viewers. Multi-tab is used to save the space of the website.

In this blog (Responsive Multi-tab Card Design), on the webpage, there are four tabs with labels. Those labels are Home, Gallery, About, Contact. You can create many tabs as much as you need. Whenever the user clicks on the labels, their respective tab with the content will be displayed. JavaScript code is used to perform the onclick function of the labels and in displaying their respective tabs.

The source code of this Responsive Multi-tab Card Design using HTML, CSS & JavaScript is given below, if you want the source code of this program, you can copy it. You can use this Responsive Multi-tab Card Design using HTML, CSS & JavaScript on your projects.

Responsive Multi tab Card Design using HTML, CSS & JavaScript [Source Code]

To make this website (Responsive Multi-tab Card Design), you need to create three files: an HTML file, a CSS file, and a JavaScript file.

First, create an HTML file with the name of index.html and remember, you have to create a file with a .html extension.

<!DOCTYPE html> <html> <head> <title>Multi tab card|| Learning robo</title> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="style.css"> </head> <body> <div class="tabs"> <div class="tab"> <button class="tablinks active" onclick="openCity(event, 'Home')" >Home</button> <button class="tablinks" onclick="openCity(event, 'Gallery')">Gallery</button> <button class="tablinks" onclick="openCity(event, 'About')">About</button> <button class="tablinks" onclick="openCity(event, 'Contact')">Contact</button> </div> <div id="Home" class="tabcontent" style="display:block"> <h3>HOME</h3> <p>Home content....</p> </div> <div id="Gallery" class="tabcontent"> <h3>GALLERY</h3> <p>Gallery content....</p> </div> <div id="About" class="tabcontent"> <h3>ABOUT</h3> <p>About content....</p> </div> <div id="Contact" class="tabcontent"> <h3>CONTACT</h3> <p>Contact content....</p> </div> </div> <div class="credit">Made with <span style="color:tomato">❤</span> by <a href="https://www.learningrobo.com/">Learning Robo</a></div> <script src="script.js"></script> </body> </html>
CSS provides style to an HTML page. To make the page attractive create a CSS file with the name style.css and remember that you have to create a file with a .css extension.


body {font-family: Arial;
    background-color: #8BC6EC;
    background-image: linear-gradient(135deg, #8BC6EC 0%, #9599E2 100%);
}
.tabs{
    width:85%;
    margin:55px auto 25px;
    border-radius:12px;
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
.tab {
  overflow: hidden;
  height:60px;
  background-color:#1c2841;
  border-radius:12px 12px 0 0 ;
}
.tab button {
  background-color: inherit;
  float: left;
  width:25%;
  height:60px;
  border: none;
  outline: none;
  cursor: pointer;
  padding: 14px 16px;
  transition: 0.3s;
  font-size: 17px;
  background-color:#1c2841;
  color:#ddd;

}
.tab button:hover {
    background-color:#12192c;
}
.tab button.active {
    background-color:#12192c;
  color:#fff;
}
.tabcontent {
  display: none;
  padding: 6px 12px;
  border-top: none;
  background-color: #12192c;
  color:#ddd;
  border-radius:0 0 12px 12px;
  height:450px;
}
.credit{
    text-align: center;
    color: #000;
    font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif;
}
.credit a{
    text-decoration: none;
    color:#000;
    font-weight: bold;
}
JavaScript makes the page work functionally. At last, create a JavaScript file with the name of script.js and remember that you've got need to make a file with a .js extension.


function openCity(evt, cityName) {
    var i, tabcontent, tablinks;
    tabcontent = document.getElementsByClassName("tabcontent");
    for (i = 0; i < tabcontent.length; i++) {
      tabcontent[i].style.display = "none";
    }
    tablinks = document.getElementsByClassName("tablinks");
    for (i = 0; i < tablinks.length; i++) {
      tablinks[i].className = tablinks[i].className.replace(" active", "");
    }
    document.getElementById(cityName).style.display = "block";
    evt.currentTarget.className += " active";
  }
We hope you would like this Responsive Multi-tab Card Design using HTML, CSS & JavaScript.

Thank you for reading our blog. If you face any problem in creating this Responsive Multi-tab Card Design using HTML, CSS & JavaScript, then contact us or comment us. We’ll try to provide a solution to your problem as soon as possible.

Thank you
Learning robo team

إرسال تعليق

Thank you
Learning robo team

Post a Comment (0)

أحدث أقدم
Learning Robo says...
code copied
Welcome