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.
.container
.response-group
header
h2
strong Lesson Title
i.fa.fa-angle-right
span.header-dropdown-trigger Activity Title
.header-dropdown
.panel
ul
- 4.times do
li
h2 Activity Title
span 2/4
.progress
.progress__complete
.response
.response__number 1
h1.response__title Coffee emporium avondale humid german rivertown vine street findlay market historic architecture?
.post-group
-3.times do
.post
.post__avatar
h3.post__author Lester McTester
h4.post__timestamp Oct 13 at 8:51pm
p.post__body Hamilton county river front museum center washington park breweries walnut hills findlay market christian moerlein flying pig ohio valley jazz festival union terminal fifty west coffee emporium chili.
.post__actions
.button.button--approve
i.fa.fa-thumbs-o-up
i.fa.fa-thumbs-up.solid
.button.button--deny
i.fa.fa-thumbs-o-down
i.fa.fa-thumbs-down.solid
.button.button--fill.comment-trigger
span Comment...
.button.button--flag
i.fa.fa-comment-o
i.fa.fa-comment.solid
| 2
.post__comments
.comment-group
- 2.times do
.post
.post__avatar.comment__avatar
h3.post__author Lester McTester
h4.post__timestamp Oct 13 at 8:51pm
p.post__body Hamilton county river front museum center washington park breweries walnut hills findlay market christian moerlein flying pig ohio valley jazz festival union terminal fifty west coffee emporium chili.
.comment-form
.comment-form__avatar
textarea
.comment-form__actions
.button.button--light.cancel Cancel
.button.button--confirm Comment
$lightgray: #ebeff1
$gray: #cdd7dc
$darkgray: #89989c
$green: #5fbc71
$blue: #4ab2d9
$red: #f26f54
$padding: 15px
$border-radius: 2px
$box-shadow: 0 2px 1px rgba(0, 0, 0, 0.15)
*
box-sizing: border-box
html
color: #4d4d4d
background-color: $lightgray
font-family: "Signika"
font-size: 16px
font-weight: 300
text-rendering: optimizeLegibility
-webkit-font-smoothing: antialiased
h1
font-size: 26px
font-weight: 700
h2
font-size: 18px
font-weight: 400
h3
font-size: 18px
font-weight: 700
h4
font-size: 12px
font-weight: 400
color: $darkgray
ul
list-style: none
padding: 0
margin: 0
%avatar
position: absolute
top: 15px
left: 15px
height: 50px
width: 50px
background-color: $darkgray
border-radius: 50%
%button
position: relative
display: inline-block
width: initial
height: 35px
padding: 0 10px
margin-left: 15px
background-color: white
color: #4ab2d9
line-height: 35px
font-weight: 400
text-align: center
border-radius: $border-radius
cursor: pointer
border: 1px solid #4ab2d9
-webkit-transition: all 0.1s
-o-transition: all 0.1s
transition: all 0.1s
&:hover
background-color: $blue
color: #FFF
%panel
position: relative
padding: $padding
background-color: #FFF
border-radius: $border-radius
box-shadow: $box-shadow
.panel
@extend %panel
.container
width: 90%
max-width: 900px
margin: 50px auto 100px
.response-group
position: relative
width: 100%
padding: 100px $padding $padding
background-color: #fff
border-radius: $border-radius
box-shadow: $box-shadow
> header
position: absolute
top: 0
left: 0
right: 0
padding: 5px $padding
background-color: transparentize(#FFF,0.25)
border-radius: $border-radius
box-shadow: $box-shadow
z-index: 100
i
margin: 0 10px 0 20px
.header-dropdown-trigger
border: 1px solid transparent
padding: 10px
border-radius: $border-radius
cursor: pointer
&:after
content: "\f078"
font-family: "FontAwesome"
font-size: 0.5em
line-height: 2.5
vertical-align: top
margin-left: 5px
&:hover, &.active
border: 1px solid $gray
> .header-dropdown
display: none
position: relative
top: -38px
left: -16px
width: calc(100% + 32px)
padding: $padding 1px
background: $lightgray
&.expand
display: block
ul
margin: -$padding
//padding: 10px 0
li
padding: 1em $padding
cursor: pointer
border-bottom: 1px solid $lightgray
h2
display: inline-block
margin: 0
&:hover h2
font-weight: 700
span
float: right
margin-left: 15px
line-height: 1.25
.progress
float: right
width: 50%
margin: 0.25em 0
.progress
position: relative
width: 100%
height: 0.75em
border-radius: 2px
background-color: $lightgray
box-shadow: 0 1px 1px rgba(0,0,0,0.1) inset
.progress__complete
position: absolute
top: 0
width: 50%
height: 0.75em
background-color: $green
border-radius: 2px
box-shadow: $box-shadow
.response
position: relative
.response__number
position: absolute
width: 2rem
height: 2rem
line-height: 1.8rem
font-size: 1.2em
font-weight: 700
text-align: center
color: $darkgray
border: 2px solid $gray
border-radius: 50%
.response__title
margin-left: 3.25rem
margin-bottom: 50px
.post-group
margin-left: 3.5rem
.post
position: relative
padding: $padding $padding 0 80px
margin-bottom: 50px
border: 1px solid $lightgray
border-bottom: none
box-shadow: $box-shadow
.post__avatar
@extend %avatar
.post__author
margin-top: 5px
margin-bottom: 5px
.post__timestamp
margin-top: 0
.post__actions
height: 40px
width: calc(100% + 95px)
margin-left: -80px
background-color: $lightgray
border-top: 1px solid $lightgray
.button
float: left
height: 40px
width: 40px
line-height: 40px
text-align: center
vertical-align: top
border-right: 1px solid $gray
i.solid
display: none
&:not(.comment):active i
transform: scale(1.2)
&:not(.comment-trigger):hover, &:not(.comment-trigger).active
background-color: #FFF
cursor: pointer
i.solid
display: inline-block
i:not(.solid)
display: none
&.button--approve
color: $green
&.button--deny
color: $red
.button--flag
width: 60px
border-right: none
font-weight: 400
i
margin-right: 5px
.button--fill
width: calc(100% - 140px)
padding: 0 10px
text-align: left
font-size: 16px
font-weight: 400
color: $darkgray
.post__comments
display: none
padding: 15px
.comment-group
padding-bottom: $padding
.post
padding: $padding $padding 0 65px
margin-bottom: 15px
box-shadow: none
.post__avatar
height: 35px
width: 35px
.comment-form
@extend %panel
height: 100%
padding: $padding $padding $padding 65px
textarea
width: 100%
height: 4em
margin-bottom: 10px
font-size: 16px
border: 1px solid $gray
border-radius: $border-radius
box-shadow: 0 1px 1px $lightgray inset
&:focus
outline: none
.comment-form__avatar
@extend %avatar
height: 35px
width: 35px
.comment-form .comment-form__actions
text-align: right
.button
@extend %button
float: none
.button--confirm
border-color: $green
color: $green
&:hover
background-color: $green
color: #FFF
.button--light
border-color: transparent
color: $darkgray
&:hover
background-color: $darkgray
color: #FFF
.post--commenting
.post__actions
height: initial
.button.comment-trigger span
display: none
.post__comments
display: block
margin-top: 40px
border-top: 1px solid $gray
$( ".header-dropdown-trigger" ).click(function() {
$( this ).toggleClass( "active" );
$( ".header-dropdown" ).toggleClass( "expand" );
});
$( ".header-dropdown li" ).click(function() {
$( ".header-dropdown-trigger" ).removeClass( "active" );
$( ".header-dropdown" ).removeClass( "expand" );
});
$( ".button--approve" ).click(function() {
$( this ).toggleClass( "active" );
$( this ).siblings( '.button--deny' ).removeClass( "active" );
});
$( ".button--deny" ).click(function() {
$( this ).toggleClass( "active" );
$( this ).siblings( '.button--approve' ).removeClass( "active" );
});
$( ".comment-trigger" ).click(function() {
$( this ).parent().parent().toggleClass( "post--commenting" );
});
$( ".button--flag" ).click(function() {
$( this ).parent().parent().toggleClass( "post--commenting" );
});
$( ".button--confirm" ).click(function() {
$( this ).parent().parent().parent().parent().parent().toggleClass( "post--commenting" );
});
$( ".button.cancel" ).click(function() {
$( this ).parent().parent().parent().parent().parent().toggleClass( "post--commenting" );
});
Also see: Tab Triggers