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.
- dayOfWeek = [ 'sun', 'mon', 'tue', 'wed', 'thr', 'fri', 'sat']
.bg
#calendar
header
i.icons.icon-arrow-left
p.month May 2016
i.icons.icon-arrow-right
| <div class="dayOfWeeks">
- for (i=0; i<7; i++)
span(class='#{dayOfWeek[i]}')=dayOfWeek[i]
| </div>
.weeks
| <div class="week">
- for (i=1; i<=31;)
- for (j=0; j<7; j++)
- if(i <= 31)
- if (i === 1)
- j = 5
- if( j === 0)
| <div class="week">
div(id='d#{i}' class='day')
.date
span.day=i
span(class='#{dayOfWeek[j]} dayOfWeek')=dayOfWeek[j]
.events
- if(i%3===0 || i%8===0)
.event
.logo
i.icon-music-tone-alt
.title
p Music Event Title
- else
.event
.logo
i.icon-game-controller
.title
p Game Event Title
- if(i%4===0)
.event
.logo
i.icon-camera
.title
p Photo Event Title
- if(i%7==0)
.event
.logo
i.icon-film
.title
p Movie Event Title
- if (j === 6)
| </div>
- i++;
// just styling///////////////////////////////
@import 'nib';
global-reset()
black = #575757
gray = #F7F7F7
red = #F78686
blue = #86BBF7
.sun
color red
.sat
color blue
*
box-sizing border-box
:root
font-size 16px
font-family 'Roboto'
font-weight 300
html
display block
height auto
color black
.bg,
.border
position fixed
top 0
left 0
width 100%
height 100%
.bg
background linear-gradient(bottom, red, #BBFCFC)
z-index -1
.border
border 15px solid white
z-index 10
.border
15px solid white
position fixed
top 0
left 0
#calendar
margin 0 auto
display block
background rgba(white, .4)
header
display flex
justify-content space-between
padding 1.5rem 0
border-bottom 1px solid red
p.month
text-align center
font-size 1.5rem
font-size 1.5rem
i.icons
padding 0.4rem
// begin calendar css//////////////////////////
#calendar
.dayOfWeeks
display none
.week
display block
> .day
display flex
border-bottom 1px solid lightness(gray,90%)
padding 1rem .5rem
// background rgba(#fff, .4)
min-height 80px
&#d12 //today
border-bottom 1px solid red
.date
flex 0 0 80px
display flex
justify-content space-between
align-items baseline
padding 0 2rem 0 0
text-align right
span
&.day
font-size 1.2rem
flex 0 0 30px
&.dayOfWeek
font-size 0.8rem
margin 0 0 0 0.2em
text-transform uppercase
.events
width 100%
.event
display flex
margin 0 0 0.5rem 0
&:last-child
margin 0
.logo
flex 0 0 20px
margin 0 0.5rem 0 0
font-size 1.0rem
.title
font-size 1.0rem
@media only screen and (min-width : 700px)
#calendar
margin-top 5vh
max-width 1000px
padding 5rem
header
margin-bottom 4rem
border none
width 90%
margin-left auto
margin-right auto
.dayOfWeeks
display flex
justify-content space-between
text-transform uppercase
margin 0 0 2rem 0
span
text-align center
flex 0 0 calc(100% / 7)
.week
display flex
&:first-child
justify-content flex-end
> .day
flex 0 0 calc(100% / 7)
margin 0
padding 0.5rem
height auto
display block
height 110px
border none
&#d12 //today
border none
.date
.day
&:after
content ''
position absolute
bottom -0.2rem
left 0
width 100%
border-bottom 1px solid red
.date
justify-content center
text-align center
margin 0 0 1.5rem 0
padding 0
.dayOfWeek
display none
.day
position relative
.events
display flex
justify-content center
.event
margin 0 .5rem 0 0
&:last-child
margin 0
.logo
margin 0
.title
margin 0.5rem
display none
Also see: Tab Triggers