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.
.page
.text Scroll for cascading text effects!
- const effects = ['random', 'enter', 'swapsies', 'fading', 'flipping', 'slide', 'karaoke', 'spinning', 'filling', 'blocks', 'scaling', 'turning', 'folding', 'bulge', 'tumbling', 'rolling', 'perspective', 'zipping', 'swinging', 'bubbling', 'blowing', 'meeting', 'conveyor']
each val in effects
.text(data-scroll='out', data-splitting='', class=`text--${val}`)= `${val.charAt(0).toUpperCase()}${val.substr(1)}`
@import url('https://fonts.googleapis.com/css?family=Lato:700')
*
box-sizing border-box
body
font-family 'Lato', sans-serif
margin 0
padding 0
.page
height 100vh
overflow auto
.text
align-items center
color #fff
display flex
font-size 3rem
height 100vh
justify-content center
overflow hidden
text-align center
width 100vw
@media(min-width 768px)
font-size 5rem
&:nth-child(n)
background #7e05d7
&:nth-child(2n)
background #f21e56
&:nth-child(3n)
background #bd04a9
// Splitting related code
.char
display inline-block
animation-delay calc(.25s + var(--char-index) * .1s)
transition all .25s calc(.25s + var(--char-index) * .1s)
random(min, max)
return floor(math(0, 'random')*(max - min + 1)) + min
.text
&--enter
[data-scroll='out'] .char
opacity 0
transform translate(0, -150%)
.char
opacity 1
transform translate(0, 0)
&--random
random()
return floor(math(0, 'random')*(250 - 25 + 1) + 25)
[data-scroll='out'] .char
for $i in (1..6)
&:nth-of-type({$i})
$x = random()
$y = random()
if ($x % 2 eq 1)
$x = $x * -1
if ($y % 2 eq 1)
$y = $y * -1
transform translateX($x * 1%) translateY($y * 1%)
&--swapsies
[data-scroll='in'] .char
[data-scroll='out'] .char
&:nth-of-type(odd)
transform translateX(100%)
&:nth-of-type(even)
transform translateX(-100%)
[data-scroll='in'] .char
animation-duration .5s
animation-fill-mode forwards
&:nth-of-type(odd)
animation-name swap-left
&:nth-of-type(even)
animation-name swap-right
@keyframes swap-right
25%
transform translateX(-100%) translateY(-100%)
75%
transform translateX(0) translateY(-100%)
100%
transform translateX(0) translateY(0)
@keyframes swap-left
25%
transform translateX(100%) translateY(100%)
75%
transform translateX(0) translateY(100%)
100%
transform translateX(0) translateY(0)
&--fading
[data-scroll='out'] .char
opacity 0
&--flipping
[data-scroll='out'] .char
transform rotateY(180deg)
&--slide
.char
transition-delay calc((var(--char-total) - var(--char-index)) * .1s)
[data-scroll='out'] .char
opacity 0
transform translate(-300%, 0) skewX(20deg)
&--karaoke
.char
color rgba(255, 255, 255, 0.15)
transition-duration .1s
&:after
color #fff
visibility visible
[data-scroll='in'] .char:after
clip-path inset(0 0 0 0)
[data-scroll='out'] .char:after
clip-path inset(0 100% 0 0)
&--filling
.char
color rgba(255, 255, 255, 0.15)
&:after
color #fff
visibility visible
[data-scroll='in'] .char:after
clip-path inset(0 0 0 0)
[data-scroll='out'] .char:after
clip-path inset(100% 0 0 0)
&--blocks
[data-scroll='out'] .char
visibility hidden
[data-scroll='in']
overflow hidden
position relative
.char
transition-delay .5s
&:after
content ''
height 100%
width 100%
position absolute
top 0
right 0
bottom 0
left 0
background #fff
animation block .5s .25s both
@keyframes block
0%
transform translate(-110%, 0)
45%, 55%
transform translate(0, 0)
100%
transform translate(110%, 0)
&--scaling
[data-scroll='out'] .char
transform scale(0)
&--turning
[data-scroll='out'] .char
transform rotateY(90deg)
&--folding
[data-scroll='out'] .char
transform rotateX(90deg)
transform-origin bottom
&--bulge
[data-scroll='in'] .char
animation-name bulge
animation-duration .25s
@keyframes bulge
50%
transform scale(1.5)
&--perspective
perspective 1000px
.char
transition transform .25s calc(.25s + var(--char-index) * .1s), opacity .05s calc(.25s + var(--char-index) * .1s)
[data-scroll='out'] .char
opacity 0
transform translate3d(-25px, -20px, -800px)
&--zipping
.char
transition transform .25s calc(.25s + var(--char-index) * .1s), opacity .05s calc(.25s + var(--char-index) * .1s)
[data-scroll='out'] .char
opacity 0
&:nth-of-type(odd)
transform translate(0, -100%)
&:nth-of-type(even)
transform translate(0, 100%)
&--spinning
[data-scroll='out'] .char
transform rotateY(-360deg)
&--tumbling
.char
transition-delay calc((var(--char-total) - var(--char-index)) * .1s)
[data-scroll='out'] .char
opacity 0
transform translate(-300%, -50%) rotate(1080deg) scale(0)
&--bubbling
.char
for $i in (1..8)
&:nth-of-type({$i})
transition-delay (random(8, 1) * .1s)
transition-timing-function cubic-bezier(0.75, -2, .75, 2)
[data-scroll='out'] .char
transform scale(0.5)
&--swinging
.char
transform-origin calc((var(--char-total) - var(--char-index)) * 100%) -100%
transition-delay calc((var(--char-total) - var(--char-index)) * .1s)
[data-scroll='out'] .char
opacity 0
transform rotate(90deg)
&--rolling
.char
transition transform 1s, opacity .2s
transition-delay calc((var(--char-total) - var(--char-index)) * .1s)
[data-scroll='out'] .char
opacity 0
transform translate(-500%, 0) scale(0) rotate(-1440deg)
&--blowing
.char
animation-duration 1s
animation-fill-mode both
transform-origin left bottom
animation-delay calc(var(--char-index) * .025s)
[data-scroll='in'] .char
animation-name blowing
@keyframes blowing
50%, 60%, 70%
transform skewX(-35deg)
55%, 65%, 75%
transform skewX(-40deg)
&--meeting
.char
transition-delay calc((var(--char-total) - var(--char-index)) * .1s)
&:nth-of-type(even)
transform-origin top right
&:nth-of-type(odd)
transform-origin bottom left
[data-scroll='out'] .char
transform rotate(180deg)
&--conveyor
[data-scroll='in'] .char
transform-origin left bottom
animation convey 1s both linear
animation-delay calc((var(--char-total) - var(--char-index)) * .15s)
transition none
@keyframes convey
0%
transform translate(calc((var(--char-total) - (var(--char-total) - var(--char-index))) * -100%), 0) rotate(-180deg) translate(calc((var(--char-total) - var(--char-index)) * -100%), 0)
40%
transform translate(calc((var(--char-total) - (var(--char-total) - var(--char-index))) * -100%), 0) rotate(-180deg) translate(0, 0)
50%
transform translate(calc((var(--char-total) - (var(--char-total) - var(--char-index))) * -100%), 0) rotate(0deg) translate(0, 0)
100%
transform translate(0, 0) rotate(0deg) translate(0, 0)
const { Splitting, ScrollOut } = window
Splitting()
ScrollOut({
targets: '.word',
scrollingElement: '.page',
})
Also see: Tab Triggers