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.
.pond
div
- let count = 3
- while(count--)
.fish
.part.head
.part.body
.part.tail
div
- count = 8
- while(count--)
.ripple
.film
.quote
.frame.wave
.frame.wave.oppo
.frame.wave
figure
blockquote
span.wave Be water,
br
span.wave.oppo my friend.
figcaption
span.wave - Bruce Lee
//- Filters
svg(xmlns="http://www.w3.org/2000/svg" version="1.1")
defs
filter#goo
feGaussianBlur(in="SourceGraphic" stdDeviation="5" result="blur")
feColorMatrix(in="blur" mode="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 19 -9" result="goo")
//feBlend(in="SourceGraphic" in2="goo")
feComposite(in="SourceGraphic" in2="goo" operator="atop")
svg(xmlns="https://wrw.w3.org/2000/svg")
filter#displacementFilter(x="0" y="0" width="100%" height="100%")
feTurbulence#sea-filter(type="turbulence" baseFrequency="0.02 0.05" numbOctaves="3" seed="2" result="turbulence")
feDisplacementMap(in2="turbulence" in="SourceGraphic" scale="50" xChannelSelector="R" yChannelSelector="G")
animate(xlink:href="#sea-filter" attributeName="baseFrequency" dur="60s" keyTimes="0;0.5;1" values="0.02 0.06;0.04 0.08;0.02 0.06" repeatCount="indefinite")
@use "sass:math"
@use "sass:map"
// font import
@import url('https://fonts.googleapis.com/css2?family=Yeseva+One&display=swap')
$size: 27
$p: 38
$R: math.sqrt($p * $p + $size * $size) /*/55.9px /* sqrt(var(--p) * var(--p) + var(--size)*var(--size)) */
$sizeU: $size+px
$pU: $p+px
$RU: $R+px
// global reset
*
box-sizing: border-box
margin: auto
// body setup
body
position: relative
height: 100vh
display: flex
background: radial-gradient(circle at bottom right, #007cb7, #83b4b6 69%, #e6ecebaf 70%, #00abc5), #00abc5
overflow: hidden
perspective: 1440px
font-family: "Yeseva One"
svg
position: absolute
// the stuff
.quote
position: relative
width: 90%
max-width: 90vh
aspect-ratio: 1/1
display: flex
flex-direction: column
border-radius: 20px 20px 50% 50%
overflow: hidden
text-align: center
word-wrap: no-wrap
filter: drop-shadow(-20px 20px 5px #006793)
figure
margin: auto
font-size: clamp(12vh, 12vh, 6rem)
filter: drop-shadow(0 0 5px #006793)
blockquote
span.wave
background: -50% 0%/ 200% 100% linear-gradient(90deg,#ffffff0f,#006793, #ffffff0f)
background-position: -50% 0
-webkit-background-clip: text
background-clip: text
color: transparent
animation: flow 5s linear infinite, sheen 10s linear infinite
&.oppo
animation-direction: reverse
figcaption
font-size: clamp(8vh, 8vh, 4rem)
text-align: right
.frame
position: absolute
width: 100%
height: 100%
background: #ffffff
@for $i from 0 to 3
&:nth-of-type(#{$i+1})
height: ($i+1)*33.3%
opacity: .8-($i+1)*.2
.pond
position: absolute
width: 100%
height: 100%
background: #ffff000f
.film
position: absolute
width: 100%
height: 100%
backdrop-filter: blur(8px)
background-size: cover
filter: url(#displacementFilter) url(#goo)
.ripple
position: absolute
width: 50vw
aspect-ratio: 1/1
border-radius: 50%
border: 5px solid #fff
transform-origin: center
transform: translate(-50%, -50%) scale(0)
opacity: 0
animation: ripple 5s ease-in-out infinite
@for $i from 0 to 8
&:nth-of-type(#{$i+1})
width: random(25)+25vw
top: random(100)+vh
left: random(100)+vw
border-width: random(3)+2+px
animation-duration: random(5)+5s
animation-delay: random(2)+random()+s
.fish
position: absolute
width: 38px
aspect-ratio: .3/1
// background: #fff
display: flex
flex-direction: column
filter: url(#goo)
animation: voyage 20s linear infinite
transform: rotate(38deg)
.part
width: 100%
// height: 33.3%
flex-grow: 2
background: #006793
&.head
transform-origin: bottom center
clip-path: polygon(50% 0%, 100% 100%, 0% 100%)
animation: swim 1.3s linear infinite
&.tail
transform-origin: top center
flex-grow: 4
clip-path: polygon(50% 100%, 100% 0%, 0% 0%)
animation: swim 1.3s linear infinite reverse
$fish: (0: ('top': 110vh, 'left': 30vw),1: ('top': 50vh, 'left': -5vw),2: ('top': 110vh, 'left': 70vw))
@for $i from 0 to 3
&:nth-of-type(#{$i+1})
top: map.get(map.get($fish, $i), 'top')
left: map.get(map.get($fish, $i), 'left')
animation-delay: $i+random()*.5s
animation-duration: random(10)+10s
.wave
-webkit-mask: radial-gradient(#{$RU} at 50% calc(100% - (#{$sizeU} + #{$pU})),blue 99%,#0000 101%) , radial-gradient(#{$RU} at 50% calc(100% + #{$pU}),#0000 99%,red 101%) repeat-x
-webkit-mask-size: calc(4*#{$sizeU}) 100%
-webkit-mask-position: calc(50% - 2*#{$sizeU}) 0, 50% calc(100% - #{$sizeU})
animation: flow 5s linear infinite
&.oppo
animation-direction: reverse
// animations
@keyframes flow
100%
-webkit-mask-position: calc(50% - 6*#{$sizeU}) 0, calc(50% - 4*#{$sizeU}) calc(200% - #{$sizeU})
@keyframes swim
0%, 100%
transform: rotate(0deg)
33.3%
transform: rotate(15deg)
75%
transform: rotate(-15deg)
@keyframes voyage
100%
translate: 40vw -130vh
@keyframes sheen
100%
background-position: 150% 0%
@keyframes ripple
50%
opacity: 1
100%
opacity: 0
transform: translate(-50%, -50%) scale(1)
// media queries
@media (max-width: 700px)
.quote
figure, figure figcaption
font-size: clamp(30px, 10vw, 4rem)
Also see: Tab Triggers