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-component">
		<div class="selected" @click="toggle">{{ selected }}</div>
		<transition name="fade">
			<div class="options" v-show="isOpen">
				<div class="option" v-for="beer in beers" @click="set(beer)">{{ beer }}</div>
			</div>
		</transition>
	</div>
</template>
            
          
!
            
              // Some boilerplating
* { box-sizing: border-box; }
body { font-size: 62.5%; background: #00aca0; }

// My dropdown
.my-dropdown-component {
	cursor: pointer;
	position: absolute;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%);
	min-width: 350px;
	height: 40px;
	
	// Selected
	.selected {
		position: relative;
		z-index: 2;
		display: block;
		width: 100%;
		height: 40px;
		padding: 0 20px;
		background: darken(#00aca0, 20%);
		border-radius: 10px;
		font: 1.25rem/40px 'Ubuntu', Helvetica, Arial, sans-serif;
		text-shadow: 2px 2px 0px #000;
		color: #fff;
		
		// Arrow
		&:after {
			opacity: 0.5;
			display: inline-block;
			margin-left: 10px;
			content: '▼';
		}
		
		// Hover state
		&: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(#202020, 0.25);
		font: 1.2rem 'Vollkorn', Georgia, Times, serif;
		
		// Hover state
		&:hover {
			background-color: rgba(#202020, 0.05);
		}
		
		// Reset last child for a nice layout
		&: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);
}
            
          
!
            
              // Dropdown component
const myDropdown = Vue.component('my-dropdown', {
	/*
	 * Template
	 */
	template: '#dropdown',
	
	/*
	 * Data
	 */
	data() {
		return {
			isOpen: false,
			selected: 'Select your favourite beer',
			beers: [
				'Heineken',
				'Amstel',
				'Dommolsch',
			]
		}
	},
	
	/*
	 * Methods
	 * Can be called from your template as well
	 */
	methods: {
		// Set the selected beer
		set(beer) {
			this.selected = beer;
			this.close();
		},
		
		// Toggle the isOpen state
		toggle() {
			this.isOpen = !this.isOpen;
		},
		
		// Open the dropdown
		open() {
			this.isOpen = true;
		},
	
		// Close the dropdown
		close() {
			this.isOpen = false;
		}
	}
})

// Create new Vue instance.
// This is the entry point of your app.
const app = new Vue({
  el: '#app'
})
            
          
!
999px
Loading ..................

Console