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 class="wrapper wrapper1" id="wrapper">
<p class="click-text">
What does Marsellus Wallace not look like? <span class="arrow"></span>
</p>
<ul>
<li>Black</li>
<li>Bald</li>
<li>A Bitch</li>
</ul>
</div>
<div class="wrapper wrapper2" id="wrapper2">
<p class="click-text">
Malkovich malkovich? <span class="arrow"></span>
</p>
<ul>
<li>Malkovich</li>
<li>Malkovich</li>
<li>Malkovich</li>
</ul>
</div>
<div class="wrapper wrapper3" id="wrapper3">
<p class="click-text">
What is your favourite colour? <span class="arrow"></span>
</p>
<ul>
<li>Blue</li>
<li>Yellow</li>
<li>Not Sure</li>
</ul>
</div>
body
color: white
font-family: sans-serif
background-color: #616161
font-family: 'Source Sans Pro', sans-serif
.wrapper
margin: 40px auto
width: 400px
display: block
text-align: center
transition: 0.15s ease
&.active
.arrow
transform: rotate(45deg) translate(-5px,-5px)
&:before
transform: translate(10px,0)
&:after
transform: rotate(90deg) translate(10px,0)
ul
opacity: 0.3
height: 108px
.wrapper2
ul
border: 1px solid rgba(255, 255, 255, 0.5)
li
&:first-child
margin-top: 16px
&:last-child
margin-bottom: 3px
&.active
ul
margin-top: 12px
.arrow
transform: rotate(45deg) translate(38px,38px)
opacity: 0.6
&:before
transform: translate(5px,0)
&:after
transform: rotate(90deg) translate(5px,0)
.wrapper3
.arrow
transform: rotate(0)
left: 0
&:before, &:after
background-color: transparent
width: 3px
height: 10px
display: inline-block
position: absolute
border-bottom: 12px solid white
top: 0
left: 0
transform: rotate(0)
&:before
transform: rotate(-135deg)
&:after
transform: rotate(135deg)
&.active
.arrow
transform: rotate(0)
transform: translate(0, -6px)
&:before
transform: rotate(-45deg)
&:after
transform: rotate(45deg)
.arrow
width: 13px
height: 13px
display: inline-block
position: relative
bottom: -5px
left: -10px
transition: 0.4s ease
margin-top: 2px
text-align: left
transform: rotate(45deg)
float: right
&:before, &:after
position: absolute
content: ''
display: inline-block
width: 12px
height: 3px
background-color: #fff
transition: 0.4s ease
&:after
position: absolute
transform: rotate(90deg)
top: -5px
left: 5px
.click-text
display: block
text-align: left
padding: 0 12px 16px
margin: 0
cursor: pointer
color: rgba(255, 255, 255, 0.3)
border-bottom: 1px solid rgba(255, 255, 255, 0.2)
transition: 0.15s ease
&:hover
color: rgba(255, 255, 255, 0.6)
border-bottom-color: rgba(255, 255, 255, 0.4)
ul
padding: 0
margin: 0
height: 0
overflow: hidden
opacity: 0
transition: 0.4s ease
border-bottom: 1px solid rgba(255, 255, 255, 0.5)
li
list-style-type: none
margin: 0 auto
padding: 4px 12px
text-align: left
cursor: pointer
&:first-child
margin-top: 12px
&:last-child
margin-bottom: 12px
document.getElementById('wrapper').onclick = function() {
var className = ' ' + wrapper.className + ' ';
this.className = ~className.indexOf(' active ') ?
className.replace(' active ', ' ') :
this.className + ' active';
};
document.getElementById('wrapper2').onclick = function() {
var className = ' ' + wrapper2.className + ' ';
this.className = ~className.indexOf(' active ') ?
className.replace(' active ', ' ') :
this.className + ' active';
}
document.getElementById('wrapper3').onclick = function() {
var className = ' ' + wrapper3.className + ' ';
this.className = ~className.indexOf(' active ') ?
className.replace(' active ', ' ') :
this.className + ' active';
}
Also see: Tab Triggers