css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .c
  .n Metro Tabs
  .p
    .tc
    .m
            
          
!
            
              @import url("https://fonts.googleapis.com/css?family=Montserrat:400,400i,700")
html
  background-color: #202020
  body
    margin: 0
    
.c
  background-color: #1a1a1a
  box-shadow: inset 0 0 30px rgba(0,0,0,0.3)
  border: 1px solid #333333
  border-radius: 4px
  padding: 3vh
  position: absolute
  transform: translate(-50%, -50%)
  top: 50%
  left: 50%
  .n
    margin-bottom: 2vh
    color: #262626
    font-size: 26px
    font-weight: 700
    font-family: 'Montserrat', arial
  .p
    box-shadow: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23)
    background: linear-gradient(#333333, #1a1a1a)
    border-radius: inherit
    padding: 3vh
    .tc
      display: flex
    .t
      font-family: 'Montserrat', arial
      font-size: 16px
      transition: background 0.1s, padding 0.5s
      background: #1a1a1a
      color: #666666
      padding: 2vh
      border-bottom: 1px solid #666666
      cursor: pointer
      &:nth-child(1)
        border-top-left-radius: 4px
      &:nth-last-child(1)
        border-top-right-radius: 4px
    .ta
      transition: background 0.1s, padding 0.5s
      background: linear-gradient(#404040, transparent)
      border-bottom: 0
      margin-bottom: 2px
      color: #999999
      padding: 2vh 3vh 2vh 3vh
    .m
      display: block
      padding: 2vh
      background: linear-gradient(transparent, #1a1a1a)
      border-bottom: 1px solid #666666
      border-bottom-right-radius: 4px
      border-bottom-left-radius: 4px
      .ip
        display: none
        width: 100%
        .ti
          color: #999999
          background-color: rgba(255,255,255,0.1)
          padding: 2vh
          font-family: 'Montserrat', arial
          box-shadow: 0 0 10px rgba(0,0,0,0.05)
        .in
          color: #666666
          border: 1px solid rgba(255,255,255,0.1)
          margin-top: 1.5vh
          padding: 2vh
          font-family: 'Montserrat', arial
          font-size: 14px
          
            
          
!
            
              gap = 1.25 //This is the free space after the last tab.

tabs = ["Home","Service","Jobs","About","Test"] //Add more tabs here.

title = ["Welcome to Metro Tabs.",
         "Here are our services.",
         "Interested in a job?",
         "A little about us.",
         "This is a test."] // Add titles for the tabs here.

info = ["Metro Tabs is an example of how a Basic Dynamic JQuery Tab Menu can be constructed.",
        "Well honestly, they are pretty good.. hehe",
        "Oh, you're interested in a job? That's weird, me too!",
        "In west Philadelphia born and raised. On the playground where I spent most of my days. Chilling out, maxing, relaxing all cool",
        "Yeah, this tab is actually just a test, sorry :/"
] // Add more info here.

init = () => {
  gTabs()
  $(".t:nth-child(1)").addClass("ta")
  $(".ti").text(title[0])
  $(".in").text(info[0])
  $(".ip:nth-child(1)").fadeIn(400)
}

gTabs = () => {
  for (i=0; i<tabs.length; i++) {
    $(".tc").append("<div class='t'></div>")
  }
  $(".t").each(function(i) {
    $(this).text(tabs[i])
    $(".m").append("<div class='ip'><div class='ti'></div><div class='in'></div></div>")
  })
  dWidth()
}

dWidth = () => {
  var TCW = $(".tc").width()
  $(".in").css("width", TCW*gap+"px")
}

init()

$(".t").click(function() {
  $(".t").removeClass("ta")
  $(this).addClass("ta")
  
  $(".ip").fadeOut(200).delay(200)
  
  var cS = $(this).text()
  for (i=0; i<tabs.length; i++) {
    if (cS == tabs[i]) {
      p = i
      b = i+1
    }
  }
  
  $(".ip:nth-child("+b+") .ti").text(title[p])
  $(".ip:nth-child("+b+") .in").text(info[p])
  $(".ip:nth-child("+b+")").fadeIn(200)
  
})
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console