cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

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
Loading ..................

Console