HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div id="app" class="shadow">
<h1 style="text-align:center;">
<a href="https://github.com/TerryZ/v-selectmenu" target="_blank">v-selectmenu</a>
</h1>
<p style="text-align:center;">SelectMenu for Vue2</p><br>
<h2>Basic</h2>
<h5 class="mt-3">Disabled</h5>
<p>
<button class="btn btn-danger mr-3" @click="available = !available">Toggle available(v-if)</button>
<button class="btn btn-outline-secondary" @click="disabled = !disabled">Toggle disabled</button>
</p>
<p>
<v-selectmenu :data="listData"
:disabled="disabled"
@values="values"
v-if="available">
</v-selectmenu>
</p>
<div class="bg-light mb-3 p-3">
<div v-for="log in logs" :key="log.id">
<div v-text="JSON.stringify(log)"></div>
</div>
</div>
<h5 class="mt-5">Menu display direction</h5>
<div class="row">
<div class="col-md-4">
<v-selectmenu :data="menu" type="regular" align="left" >
<button type="button" class="btn btn-secondary">Align left</button>
</v-selectmenu>
</div>
<div class="col-md-4">
<v-selectmenu :data="menu" type="regular" align="center" >
<button type="button" class="btn btn-secondary">Align center</button>
</v-selectmenu>
</div>
<div class="col-md-4">
<v-selectmenu :data="menu" type="regular" align="right" >
<button type="button" class="btn btn-secondary">Align right</button>
</v-selectmenu>
</div>
</div>
<h5 class="mt-5">Embedded menu</h5>
<div class="row">
<div class="col-md-6">
<p>Regular menu with slot</p>
<p>
<button type="button" class="btn btn-secondary mr-3" @click="changeData">Menu with header</button>
<button type="button" class="btn btn-secondary" @click="toMultipleLevel">Multiple level</button>
</p>
<v-selectmenu :data="dynamic" type="regular" :embed="true" >
<!-- use slot to custom rendering menu row -->
<template #row="{ row }">
<span>
<span v-if="row.icon">(icon: {{row.icon}})</span>
<span v-html="row.content"></span>
</span>
</template>
</v-selectmenu>
</div>
<div class="col-md-6">
<p>Advanced menu with slot and custom width</p>
<v-selectmenu :data="groupData"
:embed="true"
:multiple="true"
:width="250"
key-field="id"
v-model="value2" >
<template #row="{ row }">
{{row.name}} {{row.desc}}
</template>
</v-selectmenu>
</div>
</div>
<h5 class="mt-5">Custom dropdown container width</h5>
<p>
<v-selectmenu :data="groupData" :width="300" >
</v-selectmenu>
</p>
<h5 class="mt-5">Mouse right click to call the menu</h5>
<v-selectmenu :data="menu" type="regular" :full-width="true" :right-click="true" >
<div class="jumbotron text-center" style="margin: 0;">
<h1><i class="fa fa-fw fa-mouse-pointer"></i> mouse right click to call</h1>
</div>
</v-selectmenu>
<h2 class="mt-5">Regular</h2>
<h5 class="mt-3">Regular menu</h5>
<p>
<v-selectmenu :data="menu"
type="regular"
@show="showLog"
@hide="hideLog" >
<!-- use slot to custom rendering menu row -->
<template #row="{ row }">
<span>
<fa-icon class="fa-lg mr-2" :icon="row.icon.split(',')" v-if="row.icon"></fa-icon>
<span v-html="row.content"></span>
</span>
</template>
</v-selectmenu>
</p>
<h5 class="mt-5">Regular menu with header bar</h5>
<p>
<v-selectmenu :data="menu"
type="regular"
title="Menu with header">
</v-selectmenu>
</p>
<h5 class="mt-5">Regular menu with group</h5>
<p>
<v-selectmenu :data="groupMenu" type="regular" ></v-selectmenu>
</p>
<h5 class="mt-5">Regular menu with multiple level</h5>
<p>
<v-selectmenu :data="multiLevel" type="regular" >
<template v-slot="{ show, disabled }">
<button type="button" class="btn btn-primary">
SelectMenu (show: <b v-text="show"></b>, disabled: <b v-text="disabled"></b>)
</button>
</template>
</v-selectmenu>
</p>
<h2 class="mt-5">Advanced</h2>
<h5 class="mt-3">Advanced menu</h5>
<pre class="p-4 bg-light">{{JSON.stringify(value1, null, 4)}}</pre>
<p>
<v-selectmenu :data="listData" v-model="value1">
</v-selectmenu>
</p>
<h5 class="mt-5">Advanced menu with slot</h5>
<p>
<v-selectmenu :data="listData"
:max-selected="3"
:multiple="true">
<template #row="{ row }">
<div v-html="`${row.name} (${row.desc})`"></div>
</template>
</v-selectmenu>
</p>
<h5 class="mt-5">Advanced menu with group type</h5>
<pre class="p-4 bg-light">{{JSON.stringify(value2, null, 4)}}</pre>
<p>
<v-selectmenu :data="groupData"
:max-selected="3"
:multiple="true"
key-field="id"
v-model="value2" >
</v-selectmenu>
</p>
</div>
html,body{
background-color:#f5f5f5;
}
#app{
padding: 30px;
padding-bottom: 500px;
width: 900px;
margin: 0 auto;
background-color: white;
}
Vue.use(vSelectMenu.default, {
language: 'en'
})
new Vue({
el: '#app',
data () {
return {
value1: '7',
value2: '3,5,17',
dynamic: [],
logs: [],
disabled: false,
available: true,
groupData: [{
title: 'East',
list: [
{ id: 1, name: 'Chicago Bulls', desc: '芝加哥公牛', abbr: 'CHI' },
{ id: 2, name: 'Cleveland Cavaliers', desc: '克里夫兰骑士', abbr: 'CLE' },
{ id: 3, name: 'Detroit Pistons', desc: '底特律活塞', abbr: 'DET' },
{ id: 4, name: 'Indiana Pacers', desc: '印第安纳步行者', abbr: 'IND' },
{ id: 5, name: 'Milwaukee Bucks', desc: '密尔沃基雄鹿', abbr: 'MIL' },
{ id: 6, name: 'Brooklyn Nets', desc: '布鲁克林篮网', abbr: 'BKN' },
{ id: 7, name: 'Boston Celtics', desc: '波士顿凯尔特人', abbr: 'BOS' },
{ id: 8, name: 'New York Knicks', desc: '纽约尼克斯', abbr: 'NYK' },
{ id: 9, name: 'Philadelphia 76ers', desc: '费城76人', abbr: 'PHI' },
{ id: 10, name: 'Toronto Raptors', desc: '多伦多猛龙', abbr: 'TOR' },
{ id: 11, name: 'Atlanta Hawks', desc: '亚特兰大老鹰', abbr: 'ATL' },
{ id: 12, name: 'Charlotte Hornets', desc: '夏洛特黄蜂', abbr: 'CHA' },
{ id: 13, name: 'Miami Heat', desc: '迈阿密热火', abbr: 'MIA' },
{ id: 14, name: 'Orlando Magic', desc: '奥兰多魔术', abbr: 'ORL' },
{ id: 15, name: 'Washington Wizards', desc: '华盛顿奇才', abbr: 'WAS' }
]
}, {
title: 'West',
list: [
{ id: 16, name: 'Denver Nuggets', desc: '丹佛掘金', abbr: 'DEN' },
{ id: 17, name: 'Minnesota Timberwolves', desc: '明尼苏达森林狼', abbr: 'MIN' },
{ id: 18, name: 'Oklahoma City Thunder', desc: '俄克拉荷马雷霆', abbr: 'OKC' },
{ id: 19, name: 'Portland Trail Blazers', desc: '波特兰开拓者', abbr: 'POR' },
{ id: 20, name: 'Utah Jazz', desc: '犹他爵士', abbr: 'UTA' },
{ id: 21, name: 'Golden State Warriors', desc: '金州勇士', abbr: 'GSW' },
{ id: 22, name: 'Los Angeles Clippers', desc: '洛杉矶快船', abbr: 'LAC' },
{ id: 23, name: 'Los Angeles Lakers', desc: '洛杉矶湖人', abbr: 'LAL' },
{ id: 24, name: 'Phoenix Suns', desc: '菲尼克斯太阳', abbr: 'PHX' },
{ id: 25, name: 'Sacramento Kings', desc: '萨克拉门托国王', abbr: 'SAC' },
{ id: 26, name: 'Dallas Mavericks', desc: '达拉斯小牛', abbr: 'DAL' },
{ id: 27, name: 'Houston Rockets', desc: '休斯顿火箭', abbr: 'HOU' },
{ id: 28, name: 'Memphis Grizzlies', desc: '孟菲斯灰熊', abbr: 'MEM' },
{ id: 29, name: 'New Orleans Pelicans', desc: '新奥尔良鹈鹕', abbr: 'NOP' },
{ id: 30, name: 'San Antonio Spurs', desc: '圣安东尼奥马刺', abbr: 'SAS' }
] }
],
listData: [
{ id: 1, name: 'Chicago Bulls', desc: '芝加哥公牛' },
{ id: 2, name: 'Cleveland Cavaliers', desc: '克里夫兰骑士' },
{ id: 3, name: 'Detroit Pistons', desc: '底特律活塞' },
{ id: 4, name: 'Indiana Pacers', desc: '印第安纳步行者' },
{ id: 5, name: 'Milwaukee Bucks', desc: '密尔沃基雄鹿' },
{ id: 6, name: 'Brooklyn Nets', desc: '布鲁克林篮网' },
{ id: 7, name: 'Boston Celtics', desc: '波士顿凯尔特人' },
{ id: 8, name: 'New York Knicks', desc: '纽约尼克斯' },
{ id: 9, name: 'Philadelphia 76ers', desc: '费城76人' },
{ id: 10, name: 'Toronto Raptors', desc: '多伦多猛龙' },
{ id: 11, name: 'Atlanta Hawks', desc: '亚特兰大老鹰' },
{ id: 12, name: 'Charlotte Hornets', desc: '夏洛特黄蜂' },
{ id: 13, name: 'Miami Heat', desc: '迈阿密热火' },
{ id: 14, name: 'Orlando Magic', desc: '奥兰多魔术' },
{ id: 15, name: 'Washington Wizards', desc: '华盛顿奇才' },
{ id: 16, name: 'Denver Nuggets', desc: '丹佛掘金' },
{ id: 17, name: 'Minnesota Timberwolves', desc: '明尼苏达森林狼' },
{ id: 18, name: 'Oklahoma City Thunder', desc: '俄克拉荷马雷霆' },
{ id: 19, name: 'Portland Trail Blazers', desc: '波特兰开拓者' },
{ id: 20, name: 'Utah Jazz', desc: '犹他爵士' },
{ id: 21, name: 'Golden State Warriors', desc: '金州勇士' },
{ id: 22, name: 'Los Angeles Clippers', desc: '洛杉矶快船' },
{ id: 23, name: 'Los Angeles Lakers', desc: '洛杉矶湖人' },
{ id: 24, name: 'Phoenix Suns', desc: '菲尼克斯太阳' },
{ id: 25, name: 'Sacramento Kings', desc: '萨克拉门托国王' },
{ id: 26, name: 'Dallas Mavericks', desc: '达拉斯小牛' },
{ id: 27, name: 'Houston Rockets', desc: '休斯顿火箭' },
{ id: 28, name: 'Memphis Grizzlies', desc: '孟菲斯灰熊' },
{ id: 29, name: 'New Orleans Pelicans', desc: '新奥尔良鹈鹕' },
{ id: 30, name: 'San Antonio Spurs', desc: '圣安东尼奥马刺' }
],
menu: [
{ content: '163 NetEase', url: 'http://www.163.com' },
{ content: 'Sina', url: 'http://www.sina.com' },
{ content: 'sm-divider' },
{ content: 'GitHub', icon: 'fab,github', url: 'https://github.com' },
{ content: 'Reddit', icon: 'fab,reddit', url: 'https://www.reddit.com' },
{ content: 'Facebook', icon: 'fab,facebook', url: 'https://www.facebook.com', disabled: true },
{ content: 'Twitter', icon: 'fab,twitter', url: 'https://twitter.com', disabled: true },
{ content: 'sm-divider' },
{ content: 'Click this menu item to trigger your callback', callback: this.doSome }
],
headerMenu: [
{ content: 'News Site', header: true },
{ content: '163 NetEase', url: 'http://www.163.com' },
{ content: 'Sina', url: 'http://www.sina.com' },
{ content: 'sm-divider' },
{ content: 'Technology Site', header: true },
{ content: 'GitHub', icon: 'fab,github', url: 'https://github.com' },
{ content: 'Reddit', icon: 'fab,reddit', url: 'https://www.reddit.com' },
{ content: 'Facebook', icon: 'fab,facebook', url: 'https://www.facebook.com', disabled: true },
{ content: 'Twitter', icon: 'fab,twitter', url: 'https://twitter.com', disabled: true },
{ content: 'sm-divider' },
{ content: 'Actions', header: true },
{ content: 'Click this menu item to trigger your callback', callback: this.doSome }
],
multiLevel: [
{ content: 'Sports news website',
icon: 'fab,github',
children: [
{ content: 'Fivb', url: 'http://www.fivb.com/' },
{ content: 'Fifa', url: 'http://www.fifa.com/' },
{ content: 'NBA',
children: [
{ content: 'NBA official site', url: 'http://www.nba.com' },
{ content: 'Chicago Bulls', icon: 'fab,github', url: 'http://www.nba.com/bulls/' },
{ content: 'Los Angeles Lakers',
children: [
{ content: 'NBA official site', url: 'http://www.nba.com' },
{ content: 'Chicago Bulls', url: 'http://www.nba.com/bulls/' },
{ content: 'Los Angeles Lakers111', url: 'www.nba.com/lakers/' }
] }
] }
] },
{ content: 'sm-divider' },
{ content: 'News',
children: [
{ content: 'BBC', url: 'http://www.bbc.com/news' },
{ content: 'CNN', url: 'http://www.cnn.com' },
{ content: 'Xinhua', url: 'http://www.xinhuanet.com' }
] },
{ content: 'Technology',
children: [
{ content: 'Github', url: 'https://github.com' },
{ content: 'StackOverflow', url: 'https://stackoverflow.com/' },
{ content: 'Reddit', url: 'https://www.reddit.com' }
] },
{ content: 'Social',
children: [
{ content: 'Facebook', url: 'https://www.facebook.com' },
{ content: 'Twitter', url: 'https://twitter.com' }
] }
],
groupMenu: [
{
title: 'Sports',
list: [
{ content: 'Fivb', url: 'http://www.fivb.com/' },
{ content: 'Fifa', url: 'http://www.fifa.com/' },
{ content: 'sm-divider' },
{ content: 'NBA official site', url: 'http://www.nba.com' },
{ content: 'Chicago Bulls', url: 'http://www.nba.com/bulls/' },
{ content: 'Los Angeles Lakers', url: 'www.nba.com/lakers/' }
]
}, {
title: 'News',
list: [
{ content: 'BBC', url: 'http://www.bbc.com/news' },
{ content: 'CNN', url: 'http://www.cnn.com' },
{ content: 'sm-divider' },
{ content: 'Xinhua', url: 'http://www.xinhuanet.com' }
]
}, {
title: 'Technology',
list: [
{ content: 'Github', url: 'https://github.com' },
{ content: 'StackOverflow', url: 'https://stackoverflow.com/' },
{ content: 'sm-divider' },
{ content: 'Reddit', url: 'https://www.reddit.com' }
]
}, {
title: 'Social',
list: [
{ content: 'Facebook', url: 'https://www.facebook.com' },
{ content: 'Twitter', url: 'https://twitter.com' }
]
}
]
}
},
methods: {
doSome () {
// console.log(this.value1);
window.alert('you can do anything in callback!')
},
showLog () {
console.log('show')
},
hideLog () {
console.log('hide')
},
values (data) {
if (data && data.length) {
this.logs.push(data)
}
},
changeData () {
this.dynamic = this.headerMenu
},
toMultipleLevel () {
this.dynamic = this.multiLevel
}
},
mounted () {
this.dynamic = this.menu
}
})
Also see: Tab Triggers