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>
<div class="ghost">
<div class="body">
<div class="bottom">
<li></li>
<li></li>
<li></li>
</div>
</div>
<div class="head">
<ul class="eyes">
<li>
<i></i>
</li><li>
<i></i>
</li>
</ul>
</div>
</div>
</main>
<h1>Ghost</h1>
<nav>
<a title="Ghost" class="this" href="https://codepen.io/abergin/pen/JYEvJN/" target="_blank">1</a>
<a title="Devil" class="latest" target="_blank" href="https://codepen.io/abergin/pen/RWpPvw/">2</a>
<a title="Goblin" target="_blank">3</a>
<a title="Vampire" target="_blank">4</a>
<a title="Werewolf" target="_blank">5</a>
<a title="Pumpkin" target="_blank">6</a>
<a title="Haunted House" target="_blank">7</a>
<a title="Zombie" target="_blank">8</a>
<a title="Eyeball" target="_blank">9</a>
<a title="Alien" target="_blank">10</a>
<a title="Raven" target="_blank">11</a>
<a title="Moon" target="_blank">12</a>
<a title="Frankenstein" target="_blank">13</a>
<a title="Bat" target="_blank">14</a>
<a title="Amulet" target="_blank">15</a>
<a title="Grave" target="_blank">16</a>
<a title="Demon" target="_blank">17</a>
<a title="Mask" target="_blank">18</a>
<a title="Creature from the Black Lagoon" target="_blank">19</a>
<a title="Skull" target="_blank">20</a>
<a title="8-bit Zombie" target="_blank">21</a>
<a title="Candy" target="_blank">22</a>
<a title="Gore" target="_blank">23</a>
<a title="Skeleton" target="_blank">24</a>
<a title="Mummy" target="_blank">25</a>
<a title="Rat" target="_blank">26</a>
<a title="Witch" target="_blank">27</a>
<a title="Black Cat" target="_blank">28</a>
<a title="Scarecrow" target="_blank">29</a>
<a title="Spider" target="_blank">30</a>
<a title="Dragon" target="_blank">31</a>
</nav>
<i class="pre"></i>
<i class="post"></i>
@import "compass"
// illustration
$scale: 1
$background-color: #182C38
$interface-color: rgba( 252, 254, 255, 1 )
@include keyframes( bounce )
100%
@include translate( -50% , -10% )
0%
@include translate( -50% , 0 )
@include keyframes( look )
100%
@include translate( 40% , 0 )
60%
@include translate( 40% , 0 )
40%
@include translate( -40% , 0 )
0%
@include translate( -40% , 0 )
.ghost
@include animation( bounce 0.75s ease-in-out 0s infinite alternate none )
position: absolute
text-align: center
font-size: 0
left: 50%
top: 50%
$solid-color: rgba( 249, 252, 255, 1 )
$diameter: 22
width: #{$diameter*$scale}vw
height: #{$diameter*$scale}vw
@media screen and (orientation: landscape)
width: #{$diameter*$scale}vh
height: #{$diameter*$scale}vh
.head , .body
position: absolute
background-color: $solid-color
.head
border-radius: 50%
margin: -#{$diameter*$scale*0.5}vw 0 0 0
width: #{$diameter*$scale}vw
height: #{$diameter*$scale}vw
@media screen and (orientation: landscape)
margin: -#{$diameter*$scale*0.5}vh 0 0 0
width: #{$diameter*$scale}vh
height: #{$diameter*$scale}vh
.eyes
position: absolute
right: 0
left: 0
top: 50%
li
position: absolute
background-color: $background-color
border-radius: 50%
overflow: hidden
margin: -#{$diameter*$scale*0.1}vw 0 0 -#{$diameter*$scale*0.1}vw
width: #{$diameter*$scale*0.2}vw
height: #{$diameter*$scale*0.2}vw
@media screen and (orientation: landscape)
margin: -#{$diameter*$scale*0.1}vh 0 0 -#{$diameter*$scale*0.1}vh
width: #{$diameter*$scale*0.2}vh
height: #{$diameter*$scale*0.2}vh
&:nth-of-type(1)
left: 30%
&:nth-of-type(2)
left: 70%
i
@include animation( look 2.95s ease-in-out 0s infinite alternate none )
position: absolute
border-radius: 50%
background-color: $solid-color
margin-top: -40%
margin-left: -40%
top: 50%
left: 50%
height: 80%
width: 80%
.body
width: #{$diameter*$scale}vw
height: #{$diameter*$scale*0.75}vw
@media screen and (orientation: landscape)
width: #{$diameter*$scale}vh
height: #{$diameter*$scale*0.75}vh
.bottom
position: absolute
right: 0
left: 0
top: #{$diameter*$scale*0.75}vw
@media screen and (orientation: landscape)
top: #{$diameter*$scale*0.75}vh
li
position: absolute
top: -1px
border-top: #{$diameter*$scale*0.25}vw solid $solid-color
@media screen and (orientation: landscape)
border-top: #{$diameter*$scale*0.25}vh solid $solid-color
&:nth-of-type(1)
left: 0
border-right: #{$diameter*$scale*0.25}vw solid transparent
@media screen and (orientation: landscape)
border-right: #{$diameter*$scale*0.25}vh solid transparent
&:nth-of-type(2)
left: 25%
border-right: #{$diameter*$scale*0.25}vw solid transparent
border-left: #{$diameter*$scale*0.25}vw solid transparent
@media screen and (orientation: landscape)
border-right: #{$diameter*$scale*0.25}vh solid transparent
border-left: #{$diameter*$scale*0.25}vh solid transparent
&:nth-of-type(3)
right: 0
border-left: #{$diameter*$scale*0.25}vw solid transparent
@media screen and (orientation: landscape)
border-left: #{$diameter*$scale*0.25}vh solid transparent
// interface
html , body , main
background-color: $background-color
font-family: 'Roboto Condensed', sans-serif
display: block
position: absolute
overflow: hidden
height: 100%
width: 100%
left: 0
top: 0
h1
font-weight: 300
color: $interface-color
position: absolute
text-align: center
letter-spacing: 0.025em
bottom: 65px
right: 0
left: 0
font-size: 7.5vw
@media screen and (orientation: landscape)
font-size: 7.5vh
a
@include transition( opacity 0.1s ease-in-out )
cursor: pointer
position: relative
border: 1px solid $interface-color
margin: 5px
font-weight: 300
text-decoration: none
width: 24px
height: 24px
display: inline-block
font-size: 15px
line-height: 24px
opacity: 0.75
color: $interface-color
&:hover
opacity: 1
&.this:before
content: ""
position: absolute
border-bottom: 7px solid $interface-color
border-left: 7px solid transparent
right: 0
bottom: 0
&.latest ~ a , &.latest ~ a:hover
cursor: default
opacity: 0.45
nav
@include translate( 0 , 100% )
@include transition( transform 0.25s ease-in-out )
overflow-x: scroll
white-space: nowrap
font-size: 0
position: absolute
padding: 30px 15px
text-align: center
bottom: -25px
right: 0
left: 0
.pre , .post
position: absolute
pointer-events: none
bottom: 0
height: 55px
width: 25px
$fade-color: rgba( $background-color , 0 )
.pre
@include background-image(linear-gradient(to right, $background-color , $fade-color ))
left: 0
.post
@include background-image(linear-gradient(to left, $background-color , $fade-color ))
right: 0
h1:hover ~ nav , nav:hover
@include translate( 0 , 0 )
Also see: Tab Triggers