Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div class="row responsive-tab-wrapper">
  <div class="col-md-3 tab-items-list">
    <ul class="resp-tabs-list">
      <li class="resp-tab-item">TAB 1</li>
      <li class="resp-tab-item">TAB 2</li>
      <li class="resp-tab-item">TAB 3</li>
    </ul>
  </div>
  <div class="col-md-9 resp-tabs-container">
    <div class="resp-tabs-container-item">
      <div class="prod-tab-content">
        <h4>TITLE TAB 1 </h4>
        <p>
          CONTENT TAB 1
        </p>
        <img src="https://source.unsplash.com/960x640/?city" alt="Image 3">
      </div>
    </div>
    <div class="resp-tabs-container-item">
      <div class="prod-tab-content">
        <h4>TITLE TAB 2 </h4>
        <p>
          CONTENT TAB 2
        </p>
        <img src="https://source.unsplash.com/960x640/?travel" alt="Image 2">
      </div>
    </div>
    <div class="resp-tabs-container-item">
      <div class="prod-tab-content">
        <h4>TITLE TAB 3 </h4>
        <p>
          CONTENT TAB 3
        </p>
        <img src="https://source.unsplash.com/960x640/?food" alt="Image 4">
      </div>
    </div>
  </div>
</div>
<div class="button-wrapper">
  <div id="next-tab">Next</div>
  <div id="prev-tab">Prev</div>
</div>
              
            
!

CSS

              
                .responsive-tab-wrapper {
  width: 800px;
  margin: 0 auto;
  -webkit-box-shadow: 0px 3px 25px -5px rgba(0, 0, 0, 0.75);
  -moz-box-shadow: 0px 3px 25px -5px rgba(0, 0, 0, 0.75);
  box-shadow: 0px 3px 25px -5px rgba(0, 0, 0, 0.75);
  margin-top: 50px;
  padding: 15px;
  display: flex;
}
.resp-tabs-container {
  padding: 30px;
}
.resp-tabs-list {
  padding: 0;
}

.resp-tabs-list i {
  margin-right: 15px;
  font-size: 24px;
}

.resp-tabs-list li {
  cursor: pointer;
  border-bottom: solid 1px #e4eae1;
  line-height: 55px;
  padding-left: 15px;
  font-weight: 300;
  font-size: 18px;
  /* transition: all 0.5s ease; */
  -webkit-transition: all 0.5s ease;
  -moz-transition: all 0.5s ease;
  -o-transition: all 0.5s ease;
  font-family: "Hammersmith One", sans-serif;
  text-transform: uppercase;
  border-left: solid 2px #fff;
  list-style: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.resp-tabs-list li:hover,
.resp-tabs-list li.resp-tab-active,
h3.resp-accordion:hover {
  background-color: #ffffff;
  /* border-bottom: 1px solid #BFE1B1; */
  border-left: solid 2px #3bc500;
}

h3.resp-tab-active,
h3.resp-tab-active:hover {
  border-bottom: 1px solid #e7edee;
}

h3.resp-accordion {
  cursor: pointer;
  font-size: 18px;
  display: none;
  font-weight: 300;
  border-bottom: 1px solid #e7edee;
  margin: 0;
  line-height: 66px;
  transition: all 0.7s ease;
  -webkit-transition: all 0.7s ease;
  -moz-transition: all 0.7s ease;
  -o-transition: all 0.7s ease;
}

h3.resp-accordion:hover {
}

.resp-tab-content {
  display: none;
}

.resp-content-active,
.resp-accordion-active {
  display: block;
}

/*-----------Vertical tabs-----------*/
.resp-arrow {
  width: 0;
  height: 0;
  float: right;
  margin-top: 27px;
  margin-right: 15px;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 7px solid;
}

h3.resp-tab-active span.resp-arrow {
  border: none;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-bottom: 7px solid;
}

/*-----------Accordion styles-----------*/
h3.resp-tab-active {
  background: #dbfdcc;
  /* !important;*/
  border-color: #d3efc8;
}

.resp-easy-accordion h3.resp-accordion {
  display: block;
}

.resp-jfit {
  width: 100%;
  margin: 0px;
}

.resp-tab-content-active {
  display: block;
  background: #e7edee;
  padding: 0 25px 25px;
}

.prod-tab-content img {
  width: 500px;
  float: right;
}

/*Here your can change the breakpoint to set the accordion, when screen resolution changed*/
@media only screen and (max-width: 980px) {
  ul.resp-tabs-list {
    display: none;
  }

  h3.resp-accordion {
    display: block;
    padding-left: 25px;
  }
}

.button-wrapper {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px; /* 调整两个 div 元素之间的间距 */
}

/* 可选样式,为 next 和 prev 按钮添加背景颜色和样式 */
#next-tab {
  background-color: #007bff; /* 调整颜色 */
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
}

#prev-tab {
  background-color: #f00; /* 调整颜色 */
  color: white;
  padding: 10px 20px;
  border-radius: 5px;
  cursor: pointer;
}

              
            
!

JS

              
                $(function () {
  var startItemIndex = 0;
  var tabItemContainer = ".resp-tabs-container";
  var tabItemList = $(".resp-tabs-list");
  var tabInterval;
  var tabIntervalTime = 5000; //In milliseconds
  var stopOnHover = true;

  tabItemList.find(".resp-tab-item").each(function (index, val) {
    var itemHeading = $(this).html();
    $(tabItemContainer)
      .find(".resp-tabs-container-item")
      .eq(index)
      .before(
        '<h3 class="resp-accordion" data-listindex="' +
          index +
          '"><span class="resp-arrow"></span>' +
          itemHeading +
          "</h3>"
      );
  });

  $(tabItemContainer)
    .find(".resp-tabs-container-item h3.resp-accordion")
    .on("click", function () {
      var itemIndex = $(this).index();
      changeIndex(itemIndex);
      clearInterval(tabInterval);
      startAutoTab();
    });

  function changeIndex(itemIndex) {
    tabItemList.find(".resp-tab-item").removeClass("resp-tab-active");
    tabItemList
      .find(".resp-tab-item:eq(" + itemIndex + ")")
      .addClass("resp-tab-active");

    if ($(window).width() < 980) {
      $(tabItemContainer).find(".resp-tabs-container-item").slideUp();
      $(tabItemContainer)
        .find(".resp-tabs-container-item:eq(" + itemIndex + ")")
        .stop()
        .slideDown();
    } else {
      $(tabItemContainer).find(".resp-tabs-container-item").hide();
      $(tabItemContainer)
        .find(".resp-tabs-container-item:eq(" + itemIndex + ")")
        .stop()
        .fadeIn();
    }

    $(tabItemContainer)
      .find("h3.resp-accordion")
      .removeClass("resp-tab-active");
    $(tabItemContainer)
      .find("h3.resp-accordion")
      .eq(itemIndex)
      .addClass("resp-tab-active");
  }
  changeIndex(startItemIndex);
  tabItemList.find(".resp-tab-item").on("click", function () {
    var itemIndex = $(this).index();
    changeIndex(itemIndex);
    clearInterval(tabInterval);
    startAutoTab();
  });

  $("#next-tab").click(function () {
    var tabLeath = $(".resp-tab-item").length;
    var itemIndex =
      $(".resp-tab-active").index() < tabLeath - 1
        ? $(".resp-tab-active").index() + 1
        : 0;
    changeIndex(itemIndex);
    clearInterval(tabInterval);
    startAutoTab();
  });

  $("#prev-tab").click(function () {
    var tabLeath = $(".resp-tab-item").length;
    var itemIndex =
      $(".resp-tab-active").index() <= tabLeath - 1
        ? $(".resp-tab-active").index() - 1
        : tabLeath - 1;
    changeIndex(itemIndex);
    clearInterval(tabInterval);
    startAutoTab();
  });

  $(document)
    .find(tabItemContainer)
    .find("h3.resp-accordion")
    .on("click", function () {
      var itemIndex = $(this).attr("data-listindex");
      changeIndex(itemIndex);
      clearInterval(tabInterval);
      startAutoTab();
    });
  function startAutoTab() {
    tabInterval = setInterval(function () {
      var isHovered = false;
      if (stopOnHover)
        isHovered =
          $("ul.resp-tabs-list").is(":hover") ||
          $("div.resp-tabs-container").is(":hover");
      if (!isHovered) {
        var totalTabs = tabItemList.find(".resp-tab-item").length;
        if (
          totalTabs ==
          $("ul.resp-tabs-list .resp-tab-item.resp-tab-active").index() + 1
        ) {
          $(".resp-tab-item").eq(0).trigger("click");
        } else {
          $(".resp-tab-item.resp-tab-active").next().trigger("click");
        }
      }
    }, tabIntervalTime);
  }
  startAutoTab();
});

              
            
!
999px

Console