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.
<html>
<body>
<div id="app">
<modal>
<template slot="callToActionText">
Test the VueJS modal here
</template>
<template slot="modalHeader">
Sign in to your account
</template>
<template slot="modalBody">
<label>E-mail</label>
<input type="email" placeholder="[email protected]">
<label>Password</label>
<input type="password" placeholder="+8 chars" auto-complete="new-password">
</template>
<template slot="modalFooter">
<button class="button">Sign in</button>
</template>
</modal>
<script type="text/x-template" id="modal">
<div class="modal">
<!-- The call to action text -->
<div class="modal__cta">
<slot name="callToActionText"></slot>
</div>
<!-- The modal button -->
<div class="modal__button">
<button class="button" @click="click">Open modal</button>
</div>
<!-- The modal dialog -->
<div class="modal__dialog" :class="{'active' : active}">
<div class="modal__content">
<button class="modal__close" @click="click">
<i class="fa fa-times"></i>
</button>
<h3 class="modal__header">
<slot name="modalHeader"></slot>
</h3>
<div class="modal__body">
<slot name="modalBody"></slot>
</div>
<div class="modal__footer">
<slot name="modalFooter"></slot>
</div>
</div>
</div>
<!-- The overlay for the modal -->
<div class="modal__overlay"></div>
</div>
</script>
</div>
</body>
</html>
body, button, input, select
font-family: 'Catamaran', sans-serif
#app
display: flex
justify-content: center
align-items: center
height: 100vh
label
color: rgba(0, 0, 0, .45)
font-size: 12px
display: block
input
border: 1px solid rgba(0, 0, 0, .10)
background: #ffffff
box-shadow: none
color: #000
padding: 16px
outline: 0
margin-bottom: 12px
border-radius: 2px
font-weight: 300
font-size: 11px
letter-spacing: 1px
&::placeholder
color: #c9c9c9
font-size: 11px
&:focus
color: #555555
background: #ffffff
border-color: #673ab7
.button
cursor: pointer
background: #673ab7
border: 0
border-radius: 50px
color: #ffffff
padding: 12px 60px
font-weight: 700
font-size: 15px
outline: 0
text-transform: uppercase
margin: 0 auto
display: table
&:hover
background: darken(#673ab7, 5%)
.modal
display: flex
justify-content: center
align-items: center
min-height: 250px
flex-direction: column
&__cta
margin: 24px 0
font-size: 24px
color: rgba(0, 0, 0, .45)
&__overlay
position: fixed
width: 100%
height: 100%
visibility: hidden
top: 0
left: 0
z-index: 1000
opacity: 0
background: #000000
transition: all .25s
&__dialog
position: fixed
top: 50%
left: 50%
width: 50%
max-width: 630px
min-width: 320px
height: auto
z-index: 2000
visibility: hidden
backface-visibility: hidden
transform: translateX(-50%) translateY(-50%)
perspective: 1300px
&.active
opacity: 1
visibility: visible
~ .modal__overlay
opacity: .9
visibility: visible
.modal__content
transform: rotateX(0deg)
opacity: 1
&__content
background: #fafafa
border-radius: 2px
padding: 24px
color: #131313
position: relative
transform-style: preserve-3d
transform: rotateX(-60deg)
transform-origin: 50% 0
opacity: 0
transition: all .25s
&__close
position: absolute
right: -16px
top: -16px
color: #fff
background: #673ab7
border: 0
outline: 0
border-radius: 50%
font-size: 16px
width: 32px
height: 32px
cursor: pointer
&__header
text-align: center
font-weight: 300
font-size: 24px
color: rgba(0, 0, 0, .45)
&__body
color: #ffffff
display: flex
margin: 0 auto
width: 100%
max-width: 400px
flex-direction: column
&__footer
margin: 24px 0
Vue.component('modal', {
template: '#modal',
data() {
return {
active: false
}
},
methods: {
click(e) {
this.active =! this.active;
}
}
});
new Vue({
el: '#app'
});
Also see: Tab Triggers