jquery-bootstrap-scrolling-tabs (html-markup)

In this example below you will see how to do a jquery-bootstrap-scrolling-tabs (html-markup) with some HTML / CSS and Javascript

Thumbnail
This awesome code was written by 185driver, you can see more from this user in the personal repository.
You can find the original code on Codepen.io
Copyright 185driver ©

Technologies

  • HTML
  • CSS
  • JavaScript
<!DOCTYPE html>
<html lang="en" >

<head>
  <meta charset="UTF-8">
  <title>jquery-bootstrap-scrolling-tabs (html-markup)</title>
  <meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Tabs</title>

  
  <link rel='stylesheet prefetch' href='https://cdn.materialdesignicons.com/2.1.19/css/materialdesignicons.min.css'>
<link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css'>
<link rel='stylesheet prefetch' href='https://rawgit.com/mikejacobson/jquery-bootstrap-scrolling-tabs/master/dist/jquery.scrolling-tabs.min.css'>

      <link rel="stylesheet" href="css/style.css">

  
</head>

<body>

    <div id="tabs">
    <ul class="nav nav-tabs" role="tablist">
      <li class="nav-item">
        <a class="nav-link active" data-index="0" data-toggle="tab" href="#tab-0" role="tab">This is number 0</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-index="1" data-toggle="tab" href="#tab-1" role="tab">This is number 1</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-index="2" data-toggle="tab" href="#tab-2" role="tab">This is number 2</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-index="3" data-toggle="tab" href="#tab-3" role="tab">This is number 3</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-index="4" data-toggle="tab" href="#tab-4" role="tab">This is number 4</a>
      </li>
      <li class="nav-item">
        <a class="nav-link" data-index="5" data-toggle="tab" href="#tab-5" role="tab">This is number 5</a>
      </li>
    </ul>
  </div>
  <div class="tab-content">
    <div class="tab-pane fade tab-style ml-3 mt-3 active show" id="tab-0" role="tabpanel">0</div>
    <div class="tab-pane fade tab-style ml-3 mt-3" id="tab-1" role="tabpanel">1</div>
    <div class="tab-pane fade tab-style ml-3 mt-3" id="tab-2" role="tabpanel">2</div>
    <div class="tab-pane fade tab-style ml-3 mt-3" id="tab-3" role="tabpanel">3</div>
    <div class="tab-pane fade tab-style ml-3 mt-3" id="tab-4" role="tabpanel">4</div>
    <div class="tab-pane fade tab-style ml-3 mt-3" id="tab-5" role="tabpanel">5</div>
  </div>
  <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.bundle.min.js'></script>
<script src='https://rawgit.com/mikejacobson/jquery-bootstrap-scrolling-tabs/master/dist/jquery.scrolling-tabs.min.js'></script>

  

    <script  src="js/index.js"></script>




</body>

</html>

/*Downloaded from https://www.codeseek.co/185driver/jquery-bootstrap-scrolling-tabs-html-markup-KZeZOJ */
.scrtabs-tab-scroll-arrow.scrtabs-tab-scroll-arrow-left {
  text-align: right;
  width: 60px; /* affects amount of scrollToActiveTab movement */
  padding-right: 6px;
}
.scrtabs-tab-scroll-arrow.scrtabs-tab-scroll-arrow-right {
  width: 48px; /* affects amount of scrollToActiveTab movement */
  padding-left: 6px;
}

/*Downloaded from https://www.codeseek.co/185driver/jquery-bootstrap-scrolling-tabs-html-markup-KZeZOJ */
  $(document).ready(() => {
    $('.nav-tabs').scrollingTabs({
      bootstrapVersion: 4,
      scrollToTabEdge: true,
      cssClassLeftArrow: 'mdi mdi-chevron-left',
      cssClassRightArrow: 'mdi mdi-chevron-right',
    }).on('ready.scrtabs', () => {
      $('.nav-link').click(() => {
        setTimeout(() => {
          $('.nav-tabs').scrollingTabs('scrollToActiveTab');
        }, 10);
      });
    });
  });

Comments