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.
<main v-cloak>
<p><button class="accent" @click="toggleModal()">Onboard Me!</button></p>
<!-- The Modal -->
<boardal v-if="modal.isOpen" :has-mask="modal.hasMask" :can-click-mask="modal.canClickMask" :has-x="modal.hasX" @toggle="toggleModal">
<article v-cloak>
<section>
<h3>Welcome!</h3>
<p>You are about to experience data collection bliss.</p>
<p>Here at [company_name], we pride our selves on collecting your pertient personal information and meta details in order to <del>track</del> fascilitate you doing just about anything.</p>
<p><button class="accent" @click="skip(1)">Let's Get Started</button></p>
<p><label><input type="checkbox" v-model="showDots" /> show dots</label></p>
<p>
<b>movement</b><br />
<label><input type="radio" v-model="orientation" value="row" /> horizontal</label><br />
<label><input type="radio" v-model="orientation" value="column" /> vertical</label>
</p>
<!-- <p><label><input type="checkbox" v-model="xray" :true-value="'visible'" :false-value="'hidden'" /> X-ray Vision</label></p> -->
</section>
<section>
<h3>Step 2: Yay!</h3>
<p>Alright! You made it to step 2... Now you have some more choices... progressing to the next screen, or skipping right to the end and missing all the things.</p>
<p><button class="primary" @click="goToStep(5)">skip to the end</button></p>
<p><button class="primary" @click="toggleModal">Bail Out!</button></p>
<p><button class="primary" @click="skip(1)">Next...</button></p>
</section>
<section>
<h3>Step 3: Bonus!</h3>
<p>Offal scenester vape, art party tumblr hexagon listicle. Banh mi vinyl offal +1 chia williamsburg, vice organic letterpress vexillologist knausgaard flannel biodiesel. Street art kitsch typewriter cornhole put a bird on it pickled. Before they sold out literally copper mug craft beer tote bag dreamcatcher, stumptown portland bicycle rights gluten-free keytar slow-carb vinyl ethical man bun. Tumeric vaporware before they sold out, retro try-hard microdosing raclette roof party neutra pabst tacos. Hashtag street art occupy, kitsch drinking vinegar master cleanse af coloring book enamel pin salvia venmo messenger bag. Disrupt PBR&B pug slow-carb salvia asymmetrical activated charcoal organic live-edge.</p>
<p><a href="https://hipsum.co/?paras=2&type=hipster-centric" target="_blank">All the Hispter You can take...</a><p>
<h4>Yay! Scrolling Content!</h4>
<p>Selfies poke blue bottle, tousled portland actually cred PBR&B gastropub wayfarers kitsch skateboard pitchfork. Organic art party enamel pin disrupt post-ironic, meggings tilde. Kombucha YOLO craft beer, fam hot chicken knausgaard meggings. Vice fanny pack gluten-free, butcher brunch church-key before they sold out cronut single-origin coffee tilde vegan iPhone umami godard biodiesel. Bushwick live-edge poke freegan, hammock cred small batch. Cardigan before they sold out shabby chic sriracha, selvage affogato flexitarian everyday carry kinfolk meggings ugh la croix freegan bitters. Post-ironic PBR&B crucifix, iceland woke craft beer iPhone tilde tofu pug.</p>
<h4>More Squid Pork Fries</h4>
<p>XOXO typewriter pork belly sriracha quinoa flannel hot chicken. Squid pork belly selfies, tacos kitsch humblebrag taxidermy air plant pug bespoke hell of gluten-free brunch post-ironic irony. Raclette 8-bit tattooed, lo-fi VHS selvage tote bag whatever gochujang freegan. Organic butcher tbh woke fam, 8-bit yr hexagon. Polaroid thundercats man braid hell of, chia shoreditch viral skateboard man bun irony fashion axe chambray. Banjo fingerstache lumbersexual edison bulb kinfolk kombucha. Offal tousled plaid, kitsch master cleanse man braid DIY hexagon.</p>
<p>Unicorn poke gastropub, blog messenger bag snackwave poutine tote bag whatever pork belly thundercats leggings kickstarter. Cray art party green juice hammock small batch. Biodiesel chartreuse semiotics, ethical umami venmo literally glossier hell of fap thundercats. Hoodie disrupt tote bag, four dollar toast cred meggings letterpress man braid art party readymade offal actually locavore cliche roof party. Microdosing poutine mixtape tilde, kinfolk blog air plant VHS brunch cornhole ennui bicycle rights ugh. Unicorn master cleanse slow-carb, health goth cornhole irony sriracha umami DIY pork belly. Before they sold out kinfolk vegan activated charcoal af.</p>
<p>Small batch photo booth slow-carb, VHS kickstarter sartorial hot chicken actually quinoa yr. Street art snackwave flexitarian copper mug disrupt post-ironic. Knausgaard gochujang occupy, bushwick vinyl truffaut intelligentsia pop-up umami. La croix thundercats plaid hella poutine stumptown. Fixie readymade actually enamel pin, crucifix mixtape tacos migas raw denim la croix hell of. La croix chartreuse schlitz, flexitarian biodiesel gastropub fam asymmetrical brunch gentrify ethical. Chicharrones tousled VHS, seitan gluten-free whatever iPhone glossier cornhole portland kombucha +1 vice fingerstache.</p>
</section>
<section>
<h3>Step 4: Magic</h3>
<p><button @click="reset()">Rewind</button></p>
</section>
<section>
<h3>Step 5: Bonus!</h3>
</section>
</article>
<footer>
<div class="forward-actions">
<!-- <button class="secondary skip" :disabled="isLastStep" v-show="!isLastStep" @click="skip(2)">Skip</button> -->
<button class="primary next" :disabled="isLastStep" v-show="!isLastStep" @click="skip(1)"><i class="fa fa-fw fa-lg" :class="nextIcon"></i></button>
<button class="accent save" :disabled="!isLastStep" v-show="isLastStep" @click="finish"><i class="fa fa-fw fa-lg fa-check"></i></button>
</div>
<div class="step-dots" v-if="hasDots">
<div class="step-dot" v-for="n in max" :class="{active: n == step}" @click="goToStep(n)"></div>
</div>
<div class="back-actions">
<button class="secondary cancel prev" :disabled="isFirstStep" xv-show="!isFirstStep" @click="skip(-1)"><i class="fa fa-fw fa-lg" :class="backIcon"></i></button>
</div>
</footer>
</boardal>
</main>
:root {
--accent: #8fd1f2;
}
[v-cloak] {
display: none;
}
.boardal {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
display: flex;
align-items: center;
justify-content: center;
&__mask {
background: rgba(#000,.65);
position: absolute;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
}
&__wrapper {
position: relative;
width: 65vw;
max-width: 60em;
min-width: 30em;
max-height: 65vh;
height: 30em;
background: #fff;
color: #333;
display: flex;
flex-direction: var(--cross, column);
border-radius: .2em;
box-shadow: 0 0 0 1px rgba(0,0,0,.2), 0 1em 2em -1em;
}
&__x {
cursor: pointer;
font-size: 2em;
line-height: .5;
opacity: .15;
&:hover {
opacity: .65;
}
}
&-enter-active,
&-leave-active {
transition: opacity .25s
}
&-enter,
&-leave-to {
opacity: 0;
}
}
// modal content sliders
article {
flex: 1 1 100%;
height: 100%;
display: flex;
flex-direction: var(--axis, row);
overflow: hidden;
}
section {
width: 100%;
visibility: hidden;
flex: 0 0 100%;
padding: 2em;
overflow: auto;
will-change: transform;
transform: translate(var(--x, 0%), var(--y, 0%));
transition: transform 300ms ease-out;
position: relative;
h2,h3,h4 {
margin-top: 0;
}
&.current {
visibility: visible;
}
}
footer {
position: relative;
text-align: right;
display: flex;
flex-direction: var(--axis-reverse, row-reverse);
justify-content: space-between;
align-items: center;
box-shadow: 0 0 0 1px rgba(#000, .1);
background: rgba(#000, .05);
&:not(:empty) {
padding: 1em;
}
}
.step-dots {
display: flex;
flex-direction: var(--axis, row);
}
.step-dot {
cursor: pointer;
width: 1em;
height: 1em;
margin: .5ch;
border-radius: 1em;
background: currentColor;
opacity: .2;
transition: transform 100ms ease-out, opacity 150ms linear;
&.active {
opacity: .7;
box-shadow: 0 0 1em -.25em;
}
&:hover {
transform: scale(1.2)
}
}
.forward-actions,
.back-actions {
flex: 1;
display: flex;
flex-direction: var(--axis, row);
}
.forward-actions {
justify-content: flex-end;
// text-align: right;
}
.back-actions {
justify-content: flex-start;
// text-align: left;
}
// boring
*, *::before, *::after {box-sizing: border-box;}
a {
color: var(--accent);
}
del {
color: #ca1e34;
font-style: italic;
}
p {
line-height: 1.5;
}
body {
margin: 0;
min-height: 100vh;
display: flex;
align-items: center;
justify-content: center;
font-family: sans-serif;
background: snow;
color: #333;
}
// broadal buttons
button {
outline: none;
font: inherit;
line-height: 1;
cursor: pointer;
padding: .5em 1em;
border-radius: .35em;
color: rgba(#000, .7);
background: rgba(#000, .1);
border: 2px solid rgba(#000, .05);
text-shadow: 0 1px 0 rgba(#fff, .4);
transition: transform 50ms ease-out;
will-change: transform;
&:active {
transform: scale(.95);
}
&:focus {
border-color: var(--accent);
box-shadow: 0 0 1em 0 var(--accent);
}
&[disabled] {
opacity: .2;
cursor: not-allowed;
}
&.primary {
border-color: transparent;
background: transparent;
font-weight: bold;
&:not([disabled]) {
color: var(--accent);
}
}
&.accent {
background: var(--accent);
&:not([disabled]) {
color: #fff;
}
}
&.secondary {
border-color: transparent;
background: transparent;
&:not([disabled]) {
color: rgba(#000, .4);
}
}
&.cancel:not([disabled]) {
color: var(--accent);
}
}
Vue.component('boardal', {
template: `
<transition name="boardal">
<div class="boardal">
<div class="boardal__mask" v-if="hasMask" @click="clickMask"></div>
<div class="boardal__wrapper">
<slot></slot>
<div class="boardal__x" v-if="hasX" @click="clickX">×</div>
</div>
</div>
</transition>
`,
props: [
'hasX',
'hasMask',
'canClickMask'
],
methods: {
clickX: function(){
this.$emit('toggle')
},
clickMask: function(){
if(this.canClickMask) {
this.$emit('toggle')
}
}
}
})
let vm = new Vue({
el: 'main',
data: {
modal: {
isOpen: false,
hasMask: true,
canClickMask: false,
hasX: false
},
step: 1,
max: 1,
showDots: true,
orientation: 'row',
// xray: 'hidden'
},
computed: {
isFirstStep: function(){
return (this.step === 1)
},
isLastStep: function(){
return (this.step === this.max)
},
hasDots: function(){
return (this.max > 1 && this.showDots)
},
x_multiplier: function(){
return (this.orientation === 'row' ? -1 : 0)
},
y_multiplier: function(){
return (this.orientation === 'row' ? 0 : -1)
},
axis: function() {
return (this.orientation === 'row' ? 'row' : 'column')
},
axisReverse: function() {
return (this.orientation === 'row' ? 'row-reverse' : 'column-reverse')
},
cross: function() {
return (this.orientation === 'row' ? 'column' : 'row')
},
crossReverse: function() {
return (this.orientation === 'row' ? 'column-reverse' : 'row-reverse')
},
nextIcon: function() {
return (this.orientation === 'row' ? 'fa-arrow-right' : 'fa-arrow-down')
},
backIcon: function() {
return (this.orientation === 'row' ? 'fa-arrow-left' : 'fa-arrow-up')
},
},
watch: {
orientation: 'setCssVars',
// xray: 'setCssVars'
},
methods: {
toggleModal: function(step) {
step = step || 1
this.modal.isOpen = !this.modal.isOpen
if(this.modal.isOpen) {
let self = this
setTimeout(function(){
self.$sections = self.$el.querySelectorAll('section')
self.max = self.$sections.length
self.goToStep(step)
}, 1)
}
},
setCssVars: function(){
this.$el.style.setProperty('--x', (((this.step * 100) - 100) * this.x_multiplier) + '%')
this.$el.style.setProperty('--y', (((this.step * 100) - 100) * this.y_multiplier) + '%')
this.$el.style.setProperty('--axis', this.axis)
this.$el.style.setProperty('--axis-reverse', this.axisReverse)
this.$el.style.setProperty('--cross', this.cross)
this.$el.style.setProperty('--cross-reverse', this.crossReverse)
// this.$el.style.setProperty('--vision', this.xray)
},
goToStep: function(step){
this.step = step > this.max ? this.max : step < 1 ? 1 : step
this.currentSection = this.$sections[this.step-1]
this.$sections.forEach(function(section){
section.classList.remove('current')
})
this.currentSection.classList.add('current')
this.currentSection.scrollTop = 0
this.setCssVars()
},
skip: function(step){
this.step+=step
this.goToStep(this.step)
},
reset: function(){
this.goToStep(1)
},
finish: function(){
this.toggleModal()
}
}
})
Also see: Tab Triggers