Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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#app
  div.container
    
    div.tabs
      
      ul.tabs__header
        li.tabs__header-item(v-for='tab in tabs' v-on:click='selectTab(tab.id)' v-bind:class='{active: activeTab == tab.id}') {{tab.name}}
      
      div.tabs__container
        ul.tabs__list(ref='tabsList')
          li.tabs__list-tab(v-for='tab in tabs' v-bind:class='{active: activeTab == tab.id}') {{tab.content}}
              
            
!

CSS

              
                html {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  background: radial-gradient(#7a5ce9, #1d2040);
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 40px auto;
}

.tabs {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;

  // Список табов для переключения
  &__header {
    $color-accent: #66bd6c;
    $border-radius: 4px;

    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
    background: #fff;
    border-radius: $border-radius $border-radius 0 0;
    border-bottom: 1px solid fade-out(#000, 0.9);
    //
    display: flex;
    flex-direction: row;
    align-items: center;

    // Кнопка одного таба
    &-item {
      flex: 1;
      text-align: center;
      padding: 10px 0;
      cursor: pointer;
      transition: background 0.3s ease;
      border-right: 1px solid fade-out(#000, 0.9);
      position: relative;

      &:first-child {
        border-radius: $border-radius 0 0 0;
      }

      &:last-child {
        border-radius: 0 $border-radius 0 0;
        border-right: 0;
      }

      &:hover {
        background: fade-out($color-accent, 0.9);
      }

      &:before {
        content: "";
        width: 8px;
        height: 8px;
        display: inline-block;
        background: #fff;
        border: 1px solid $color-accent;
        margin-right: 10px;
        border-radius: 50%;
        position: relative;
        top: 0px;
        transition: background 0.3s ease;
      }

      &:after {
        content: "";
        width: 0%;
        height: 1px;
        bottom: 0;
        left: 50%;
        position: absolute;
        transform: translate(-50%, 0%);
        background: $color-accent;
        transition: width 0.3s ease;
      }

      &.active {
        &:after {
          width: 100%;
        }

        &:before {
          background: $color-accent;
        }
      }
    }
  }

  // Контент с текстом. Обрезает лишние слайды
  &__container {
    background: #fff;
    position: relative;
    overflow-y: hidden;
  }

  // Список слайдов
  &__list {
    list-style: none;
    margin: 0;
    padding: 0;
    position: relative;
    //
    display: flex;
    flex-direction: row;
    //
    transition: all 0.3s linear;

    &-tab {
      width: 100%;
      min-width: 100%;
      padding: 10px 10px;
      box-sizing: border-box;
      position: relative;
      transition: opacity .5s ease;
      opacity: 0;
      
      &.active {
        opacity: 1;
      }
    }
  }
}

              
            
!

JS

              
                new Vue({
  el: '#app',
  
  data () {
    return {
      activeTab: 1,
      
      // Левый отступ для слайдов
      offsetRight: 0,
      
      // Список табов
      tabs: [
        {
          id: 1,
          name: 'One',
          content: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Ut convallis vel leo facilisis aliquet. Nullam finibus enim vitae ex tincidunt interdum. Pellentesque non condimentum ante, vitae viverra nibh. Integer ultrices tortor eget massa convallis pulvinar. Nullam ipsum neque, luctus ut felis non, auctor pellentesque magna. Maecenas velit neque, blandit in pharetra in, rutrum at nunc. Vestibulum non finibus quam. Sed semper aliquam varius. Sed dictum eu risus sed ultrices.'
        },
        {
          id: 2,
          name: 'Two',
          content: 'Cras id felis eu nulla pulvinar aliquet a ac elit. Ut tincidunt nisl tempus mi fermentum cursus eget et nibh. Pellentesque fermentum tincidunt mi, in tempus odio malesuada non. Mauris sit amet efficitur felis. Duis vestibulum cursus quam vel condimentum. Aliquam at tellus blandit, sodales purus non, convallis arcu. Mauris convallis sed lorem et condimentum. Aliquam neque metus, sollicitudin a est vitae, convallis finibus risus. Vivamus pulvinar imperdiet malesuada. Donec iaculis eros et sapien accumsan tincidunt.'
        },
        {
          id: 3,
          name: 'Three',
          content: 'Pellentesque ac metus odio. Nulla facilisi. Cras suscipit, tellus et vehicula faucibus, neque felis vestibulum nisi, eu consectetur ante metus eu ligula. Sed cursus posuere tellus eget tristique. Fusce venenatis ipsum nibh, hendrerit posuere massa ultrices quis. Donec interdum commodo ante id iaculis. Nulla semper nulla ut tristique vehicula. Sed porttitor justo massa, vitae consequat lectus viverra id.'
        }
      ]
    }
  },
  
  methods: {
    // Выбрать таб по id
    selectTab (id) {
      let tabsList = this.$refs.tabsList
      this.activeTab = id
      this.offsetRight = tabsList.clientWidth * (id - 1)
      // Сдвигаем полосу с табами
      tabsList.style.right = this.offsetRight + 'px'
    }
  }, 
  
  mounted () {
    // Выставляем стартовое значение
    let tabsList = this.$refs.tabsList
    tabsList.style.right = this.offsetRight + 'px'
  }
})
              
            
!
999px

Console