How're you doing guys. Please I need your help on this matter. I've found this code on codepen : https://codepen.io/grahn195/pen/oNZvwRL and it works very perfectly on codepen.io
I wanted to create three swipeable tabs, and I've succeeded to create them perfectly. But what I want is to make the middle tab to be active instead of the first tab.
<!DOCTYPE html>
<html lang="en" >
<head>
<meta charset="UTF-8">
<title>CodePen - Swipeable Tabs</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/normalize/5.0.0/normalize.min.css">
<link rel='stylesheet' href='https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.1.2/css/swiper.min.css'>
<style>
*,
*::before,
*::after {
box-sizing: inherit;
}
.swiper-container {
width: 100%;
height: 100%;
}
.swiper-slide {
background: #fff;
color: #333;
font-size: 1.8rem;
min-height: 300px;
display: flex;
justify-content: center;
align-items: center;
text-align: center;
}
.swiper-container-horizontal > .swiper-pagination {
top: 0;
bottom: auto;
}
.swiper-container-horizontal > .swiper-pagination .swiper-pagination-bullet {
margin: 0;
}
.active-mark {
background: #ffeb3b;
width: 33.33%;
height: 4px;
position: absolute;
left: 0;
top: 52px;
transition: left 0.2s ease-out;
}
.swiper-pagination-bullet {
background-color: #00D42B;
border-radius: 0;
box-sizing: border-box;
color: #0e8927;
cursor: pointer;
font-size: 1.6rem;
font-weight: normal;
opacity: 1;
height: 56px;
width: 33.33%;
display: inline-flex;
align-items: center;
justify-content: center;
text-align: center;
transition: font-weight 0.22s ease;
}
.swiper-pagination-bullet:nth-of-type(1).swiper-pagination-bullet-active ~ .active-mark {
left: 0%;
}
.swiper-pagination-bullet:nth-of-type(2).swiper-pagination-bullet-active ~ .active-mark {
left: 33.33%;
}
.swiper-pagination-bullet:nth-of-type(2).swiper-pagination-bullet-active ~ .active-mark {
left: 66.66%;
}
.swiper-pagination-bullet:first-of-type.swiper-pagination-bullet-active ~ .active-mark {
left: 0;
}
.swiper-pagination-bullet-active {
font-weight: bold;
}
</style>
<script>
window.console = window.console || function(t) {};
</script>
<script>
if (document.location.search.match(/type=embed/gi)) {
window.parent.postMessage("resize", "*");
}
</script>
</head>
<body translate="no" >
<div class="swiper-container">
<div class="swiper-pagination">
</div>
<div class="swiper-wrapper">
<div class="swiper-slide">Tab 1x</div>
<div class="swiper-slide">Tab 2x</div>
<div class="swiper-slide">Tab 3x</div>
</div>
</div>
<script src="https://cpwebassets.codepen.io/assets/common/stopExecutionOnTimeout-1b93190375e9ccc259df3a57c1abc0e64599724ae30d7ea4c6877eb615f89387.js"></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/Swiper/3.1.2/js/swiper.min.js'></script>
<script id="rendered-js" >
var swiper = new Swiper('.swiper-container', {
pagination: '.swiper-pagination',
slidesPerView: 1,
paginationClickable: true,
loop: false,
paginationBulletRender: function (index, className) {
var tabsName = ['Apps', 'Tricks', 'People'];
if (index === tabsName.length - 1) {
return '<span class="' + className + '">' +
tabsName[index] + '</span>' +
'<div class="active-mark "></div>';
}
return '<span class="' + className + '">' + tabsName[index] + '</span>';
} });
//# sourceURL=pen.js
</script>
</body>
</html>