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 program (Responsive Multi-tab Card Design), on the webpage, there are five tabs with labels. Those labels are named Item1, Item2, and so on. You can create many tabs as much as you need. When the user clicks on the labels, the respective tab with its content will be displayed. JavaScript code is used to move from one tab to the other tabs on clicking the label.
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.
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@200;400;600&display=swap');
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
a {
text-decoration: none;
color: inherit;
}
body {
font-family: 'Poppins', sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #85FFBD;
background-image: linear-gradient(45deg, #85FFBD 0%, #FFFB7D 100%);
}
ul {
list-style: none;
margin: 0;
padding: 0;
display: flex;
justify-content: space-between;
height: 30px;
}
.container {
max-width: 700px;
width: 100%;
background-color: #12192c;
padding: 30px;
border-radius: 20px;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
}
li a {
color: #fff;
}
li a:hover {
padding-bottom: 4px;
border-bottom: 3px solid #85FFBD;
}
.wrapper_tab-content {
position: relative;
}
.tab-content {
position: absolute;
padding: 1.75em 0;
visibility: hidden;
height: 0;
color:#fff
}
.tab-content h1 {
font-size: 1.12em;
margin-bottom: .5em;
}
.content-visible {
position: static;
visibility: visible;
height: auto;
}
.active {
color: #85FFBD;
padding-bottom: 4px;
border-bottom: 3px solid #85FFBD;
}
.credit a{
text-decoration: none;
color: #85FFBD;
font-weight: 800;
}
.credit {
text-align: center;
font-family: Verdana, Geneva, Tahoma, sans-serif;
margin: 10px;
color:#FFF
}
const selectTab = element => {
const active = document.querySelector('.active');
const visible = document.querySelector('.content-visible');
const tabContent = document.getElementById(element.href.split('#')[1]);
if (active) {
active.classList.remove('active');
}
element.classList.add('active');
if (visible) {
visible.classList.remove('content-visible');
}
tabContent.classList.add('content-visible');
}
document.addEventListener('click', event => {
if (event.target.matches('.tab-item a')) {
selectTab(event.target);
}
}, false);
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.
Post a Comment
Thank you
Learning robo team