cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

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.

            
              <!-- App -->
<div id="app">
	<my-dropdown></my-dropdown>
</div>

<!-- Dropdown template -->
<template id="dropdown">
  <div class="my-dropdown">
		<!-- On click we call the toggle method -->
		<div class="selected" @click="toggle">Selected value</div>

		<div class="options" v-show="isOpen">
			<div class="option">option 1</div>
			<div class="option">option 2</div>
			<div class="option">option 3</div>
		</div>
	</div>
</template>
            
          
!
            
              /* Some boilerplating */
* { box-sizing: border-box; }
body { font-size: 62.5%; background: #00aca0; }

/* My dropdown */
.my-dropdown {
  cursor: pointer;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -70px);
  min-width: 350px;
  height: 40px;
}

/* Selected */
.selected {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 40px;
  padding: 0 20px;
  background: #054641;
  border-radius: 10px;
  font: 1.25rem/40px 'Ubuntu', Helvetica, Arial, sans-serif;
  text-shadow: 2px 2px 0px #000;
  color: #fff;  
}

/* Arrow */
.selected:after {
  opacity: 0.5;
  display: inline-block;
  margin-left: 10px;
  content: '▼';
}

/* Hover state */
.selected:hover:after {
  opacity: 1;
}

/* Options wrapper (toggled by isOpen) */
.options {
  position: absolute;
  left: 0;
  top: 100%;
  z-index: 1;
  width: 100%;
  margin-top: 3px;
  background: #fff;
  border-radius: 10px;
}

/* Option */
.option {
  padding: 5px 20px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  font: 1.2rem 'Vollkorn', Georgia, Times, serif;
}

/* Hover state */
.option:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

/* Reset last child for a nice layout */
.option:last-child {
  border-bottom: none;
}

/* Transition */
.fade-enter-active, .fade-leave-active {
  transition: all .25s ease-out;
}

.fade-enter, .fade-leave-active {
  opacity: 0;
	transform: translateY(-30px);
}
            
          
!
            
              // Register my-dropdown component
var myDropdown = Vue.component('my-dropdown', {
  // Define the template, refers to the template id in the HTML.
  template: '#dropdown',

  // A data object containing all data for this component.
  data: function() {
    return {
      isOpen: false
    }
  },

  // Methods, we will bind these later on.
  methods: {
    toggle: function() {
      this.isOpen = !this.isOpen;
    },

    show: function() {
      this.isOpen = true;
    },

    hide: function() {
      this.isOpen = false;
    }
  }
});

// Create new Vue instance
var app = new Vue({
  // Tell Vue #app is the container element.
  el: '#app'
});
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console