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.
- 150.times do
.star
.title 404
.gravestones
- 3.times do
.cross
.bottompatch
- 100.times do
.patch
.msg
This page doesn't exist.
.crypt
.roof
.body
.door
.fog
.moon
@font-face
font-family: 'stranger'
src: url('https://s3-us-west-2.amazonaws.com/s.cdpn.io/455279/stranger.ttf') format('truetype')
html
background: linear-gradient(0deg, #050514, #30336b)
overflow: hidden
height: 100%
body
margin: 0
.patch
position: absolute
bottom: 0
height: 10vh
width: 3vw
background-color: black
z-index: 2
&:nth-child(odd)
background-color: rgba(0,0,0,0.9)
z-index: 0
.bottompatch
position: absolute
background-color: red
bottom: 0
left: 0
.gravestones
.cross
position: absolute
height: 28vh
width: 1.8vh
background-color: black
bottom: 0
z-index: 1
&:after
content: ""
position: absolute
background-color: inherit
height: 1.8vh
width: 10vh
top: 5vh
left: 50%
transform: translateX(-50%)
&:nth-child(1)
left: 20%
&:nth-child(2)
left: 70%
bottom: -4vh
&:nth-child(3)
left: 90%
.msg
display: none
color: black
font-size: 6.2vh
font-family: 'stranger', arial
position: absolute
bottom: 14vh
left: 50%
transform: translateX(-50%)
z-index: 2
.crypt
position: absolute
bottom: 0
left: 50%
transform: translateX(-50%)
width: 38vh
height: 40vh
.roof
height: 10vh
width: 100%
background-color: black
-webkit-clip-path: polygon(21% 0%, 79% 0%, 100% 100%, 0% 100%)
clip-path: polygon(21% 0%, 79% 14%, 100% 100%, 0% 100%)
.body
width: 86%
height: 100%
background-color: black
margin: -1vh auto 0 auto
.door
position: absolute
bottom: 0
left: 50%
transform: translateX(-50%) rotateZ(-3deg)
width: 20%
height: 45%
border-top-right-radius: 100%
border-top-left-radius: 100%
background-color: black
.fog
width: 40vh
height: 20vh
border-top-right-radius: 100%
border-top-left-radius: 100%
background-color: rgba(255,255,255,0.2)
position: absolute
bottom: 0
z-index: 1
animation-name: fog
animation-iteration-count: infinite
animation-duration: 80s
.moon
position: absolute
top: 8vh
right: 18vh
height: 20vh
width: 20vh
border-radius: 20vh
box-shadow: inset -2vh 0 0 #dfe6e9
transform: rotateZ(32deg)
.title
height: 65vh
margin: 0
position: absolute
left: 49%
bottom: -90vh
opacity: 0.1
transition: filter 3s
transform: translate(-50%, -50%) rotateZ(-4deg)
font-family: 'stranger', arial
font-size: 60vh
color: #dfe6e9
z-index: 1
.life
opacity: 1
transition: opacity 4s
animation-name: float
animation-iteration-count: infinite
animation-duration: 5s
.star
height: 1px
width: 1px
background-color: white
position: absolute
z-index: 0
@keyframes fog
0%
filter: blur(10vh)
left: -9vw
transform: rotateZ(19deg)
50%
filter: blur(13vh)
left: 109vw
100%
filter: blur(10vh)
left: 9vw
transform: rotateZ(-19deg)
@keyframes float
0%
top: 45%
50%
top: 46%
100%
top: 45%
$(".patch").each((i) => {
let b = i + 1
let rX = Math.floor(Math.random() * 50)
let rY = Math.floor(Math.random() * 100)
let rH = Math.floor(Math.random() * 10) + 15
$(".patch:nth-child("+b+")").css({
left: i-1+"vw",
height: rH+"vh",
"-webkit-clip-path": "polygon("+rX+"% "+rX+"%, 0% 100%, 100% 100%)",
"clip-path": "polygon("+rX+"% "+rX+"%, 0% 100%, 100% 100%)"
})
})
$(".cross").each((i) => {
let b = i + 1
let rR = Math.floor(Math.random() * 15) * Math.cos(Math.PI * Math.round(Math.random()))
$(".cross:nth-child("+b+")").css({
"transform": "rotateZ("+rR+"deg)"
})
})
$(".star").each((i) => {
$(".star:nth-child("+i+")").css({
top: Math.random() * $(document).height() - $(document).height()/4,
left: Math.random() * $(document).width()
})
})
init = () => {
$(".crypt").css({
"transform": "translateX(-50%) rotateZ("+Math.floor(Math.random() * 5) * Math.cos(Math.PI * Math.round(Math.random()))+"deg)"
})
$(".title").animate({
top: "45%"
}, 5000, () => {
$(".title").addClass("life")
$(".msg").fadeIn(1000)
})
}
init()
Also see: Tab Triggers