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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
ul.content
li#content-item-01.content__item
div.content__item__text
| item1
li#content-item-02.content__item
div.content__item__text
| item2
li#content-item-03.content__item
div.content__item__text
| item3
@import 'nib'
cWidth = 30px
sWidth = 200px
createGradient(type, str)
dev = 20
spl = 100 / dev
for i in (0..dev)
if i % 2 == 1
if i
str = str + ',#888 ' + ((i - 1) * spl) + '.01%'
str = str + ',#888 ' + (i * spl) + '%'
else
if i
str = str + ',#000 ' + ((i - 1) * spl) + '.01%'
str = str + ',#000 ' + (i * spl) + '%'
if type == 'linear'
str = 'linear-gradient(' + str + ')'
else
str = 'radial-gradient(' + str + ')'
background-image unquote(str)
body
display flex
flex-flow row nowrap
align-items center
justify-content stretch
min-height 100vh
.content
width 100%
min-height 100vh
background-color #ff0
display flex
flex-flow row nowrap
align-items stretch
justify-content stretch
&__item
display inline-block
background-color #0ff
width 33%
flex-grow 1
flex-shrink 1
display flex
flex-flow column nowrap
justify-content center
align-items center
position relative
overflow hidden
transition all .2s ease 0s
z-index 10
&__text
size 80px
background-color #fff
display flex
flex-flow column nowrap
justify-content center
align-items center
border-radius 50%
position relative
z-index 4
font-size 14px
transition all .2s ease 0s
&:hover
width 50%
flex-glow 2
& ^[1]__text
size 120px
font-size 18px
&::before
&::after
content ''
absolute left 50% top 50%
size 100vmax
margin-top -50vmax
margin-left -50vmax
animation-duration 20s
animation-timing-function linear
animation-delay 0s
animation-iteration-count infinite
animation-direction normal
&::before
mix-blend-mode overlay
animation-name cont_anim1
z-index 1
&::after
mix-blend-mode overlay
animation-name cont_anim2
z-index 2
color-high = #aaa
color-low = #888
&:nth-child(1)
background-image linear-gradient(
bottom left,
#ff8 0%,
#f88 100%
)
&::before
background-image repeating-linear-gradient(
-45deg,
color-high 0px, color-high 10px,
color-low 10px, color-low 20px
)
&::after
background-image repeating-linear-gradient(
45deg,
color-high 0px, color-high 10px,
color-low 10px, color-low 20px
)
&:nth-child(2)
background-image linear-gradient(
bottom left,
#f8f 0%,
#88f 100%
)
&::before
background-image repeating-radial-gradient(
-45deg,
color-high 0%, color-high 2%,
color-low 2%, color-low 4%
)
animation-name cont_anim3
&::after
background-image repeating-linear-gradient(
45deg,
color-high 0px, color-high 10px,
color-low 10px, color-low 20px
)
&:nth-child(3)
background-image linear-gradient(
bottom left,
#8ff 0%,
#8f8 100%
)
&::before,
&::after
background-image radial-gradient(
color-low 40%,
transparent 0
), radial-gradient(
color-low 40%,
transparent 0
)
background-color color-high
background-position 0 0, 10px 10px
background-size 20px 20px
@keyframes cont_anim1
to
transform rotate(0deg)
from
transform rotate(360deg)
@keyframes cont_anim2
to
transform rotate(360deg)
from
transform rotate(0deg)
@keyframes cont_anim3
0%
size 100vmax
margin-top -50vmax
margin-left -50vmax
50%
size 200vmax
margin-top -100vmax
margin-left -100vmax
100%
size 100vmax
margin-top -50vmax
margin-left -50vmax
Also see: Tab Triggers