I\'m currently trying to build a tabbed div container:
At the moment it looks like this. I can also switch the tab. Each tab has an is-active
c
Yes,you can do it using an extra tag. Call it as a slider
for now.
So, now if you click on the slider will move to and fro.
Here is code attached.
var tabs = document.getElementsByClassName('Tab');
Array.prototype.forEach.call(tabs, function(tab) {
tab.addEventListener('click', setActiveClass);
});
function setActiveClass(evt) {
Array.prototype.forEach.call(tabs, function(tab) {
tab.classList.remove('active');
});
evt.currentTarget.classList.add('active');
}
.Tabs {
position: relative;
background-color: #fff;
margin: 0;
padding: 0;
list-style: none;
}
.Tabs:after {
content: ' ';
display: table;
clear: both;
}
.description_tab {
float: left;
width: 33.333%;
text-align: center;
}
.description_tab:first-child.active ~ .slider {
left: 0;
}
.description_tab:nth-child(2).active ~ .slider {
left: 33.333%;
}
.slider {
position: absolute;
bottom: 0;
left: 0;
width: 33.333%;
height: 4px;
background-color: #4A66F4;
transition: left .25s;
}
.Tab {
font-family: 'Roboto Slab';
}
.Tab > a {
display: block;
padding: 10px 12px;
text-decoration: none;
color: #666;
transition: color .15s;
}
.Tab.active > a {
color: #222;
}
.Tab:hover > a {
color: #222;
}
JS Bin
Hope this helped you, Thank you.
Credits: from earth on codepen