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.
#header
%nav
%a{:href => "#panelOne"} Panel One
%a{:href => "#panelTwo"} Panel Two
%a{:href => "#panelThree"} Panel Three
%span#location
.panelize
%section#panelOne.panel.one
%article
.container
%header
%h1 Panel One
.content
%p It's a fez. I wear a fez now. Fezes are cool. Sorry, checking all the water in this area; there's an escaped fish. No, I'll fix it. I'm good at fixing rot. Call me the Rotmeister. No, I'm the Doctor. Don't call me the Rotmeister.
%p I'm the Doctor. Well, they call me the Doctor. I don't know why. I call me the Doctor too. I still don't know why. I hate yogurt. It's just stuff with bits in. I hate yogurt. It's just stuff with bits in. All I've got to do is pass as an ordinary human being. Simple. What could possibly go wrong?
%section#panelTwo.panel.two
%article
.container
%header
%h1 Panel Two
.content
%p I am the Doctor, and you are the Daleks! Annihilate? No. No violence. I won't stand for it. Not now, not ever, do you understand me?! I'm the Doctor, the Oncoming Storm - and you basically meant beat them in a football match, didn't you? Aw, you're all Mr. Grumpy Face today. It's a fez. I wear a fez now. Fezes are cool. The way I see it, every life is a pile of good things and bad things.…hey.…the good things don't always soften the bad things; but vice-versa the bad things don't necessarily spoil the good things and make them unimportant. Annihilate? No. No violence. I won't stand for it. Not now, not ever, do you understand me?! I'm the Doctor, the Oncoming Storm - and you basically meant beat them in a football match, didn't you?
%p You hit me with a cricket bat. You know when grown-ups tell you 'everything's going to be fine' and you think they're probably lying to make you feel better? You hit me with a cricket bat. Annihilate? No. No violence. I won't stand for it. Not now, not ever, do you understand me?! I'm the Doctor, the Oncoming Storm - and you basically meant beat them in a football match, didn't you?
%p I hate yogurt. It's just stuff with bits in. You know how I sometimes have really brilliant ideas? You hit me with a cricket bat.
%section#panelThree.panel.three
%article
.container
%header
%h1 Panel Three
.content
%p I am the last of my species, and I know how that weighs on the heart so don't lie to me! I am the last of my species, and I know how that weighs on the heart so don't lie to me! It's art! A statement on modern society, 'Oh Ain't Modern Society Awful?'! Stop talking, brain thinking. Hush. I'm the Doctor, I'm worse than everyone's aunt. *catches himself* And that is not how I'm introducing myself. No, I'll fix it. I'm good at fixing rot. Call me the Rotmeister. No, I'm the Doctor. Don't call me the Rotmeister.
%p Annihilate? No. No violence. I won't stand for it. Not now, not ever, do you understand me?! I'm the Doctor, the Oncoming Storm - and you basically meant beat them in a football match, didn't you? Did I mention we have comfy chairs? No, I'll fix it. I'm good at fixing rot. Call me the Rotmeister. No, I'm the Doctor. Don't call me the Rotmeister. You know how I sometimes have really brilliant ideas? *Insistently* Bow ties are cool! Come on Amy, I'm a normal bloke, tell me what normal blokes do!
@import compass
/////////////////
// Styles Here //
/////////////////
#header
position: fixed
z-index: 2000
background-color: rgba(0,0,0,.4)
width: 100%
nav
max-width: 900px
margin: 0 auto
a
color: white
display: inline-block
text-align: center
padding: 10px 20px
text-decoration: none
&:hover, &.active
background-color: rgba(0,0,0,.7)
#position-block
position: fixed
z-index: 1000
color: white
h1
font-family: 'Dosis'
font-style: normal
font-weight: 600
color: white
font-size: 69px
line-height: 78px
padding: 20px 0px 10px 20px
margin: 0
p
font-family: 'Ubuntu'
font-style: normal
font-weight: 400
color: white
font-size: 15px
line-height: 28px
margin-top: 0px
text-align: justify
article
position: relative
+box-shadow(black 0px 0px 15px)
header
padding-top: 30px
.content
+column-count(2)
+column-gap(60px)
padding: 0 20px 60px 20px
.container
max-width: 900px
margin: 0 auto
.panel
position: relative
width: 100%
.panel.one
article
background-color: #00AEFF
.panel.two
article
background-color: #292929
.panel.three
article
background-color: #FF3500
(($, window, document, undefined_) ->
Panelize = {
init: (elements, options) ->
self = @
# get default elements for rest of plugin
self.options = $.extend({}, $.fn.panelize.options, options)
self.outerContainer = elements
self.panels = elements.children()
if self.options.containerSelector isnt null
self.innerContainers = elements.find(self.options.containerSelector)
else
self.innerContainers = self.panels.children()
self.options.containerSelector = self.innerContainers.first().prop('tagName')
# set z-index properties for panel elements
count = self.options.startZ
self.panels.each ->
$(@).css('z-index', count)
count -= self.options.zStep
return
# set default height for panels
self.resize()
self.panels.css({
'padding-bottom': $(window).height()
'position': 'fixed'
'left': 0
'top': 0
}).addClass('static')
self.panels.first().css('position', 'relative').removeClass('static').addClass('scroll')
self.panels.last().css('padding-bottom', 0)
lastPosition = 0
$(window).on 'scroll', ->
position = $(@).scrollTop()
#$('#location').html('Top: '+ $(@).scrollTop())
$element = $('.scroll').last().find(self.options.containerSelector)
if(position > lastPosition)
# down
if(($element.offset().top + $element.outerHeight()) <= position)
staticPanels = $('.static')
$('.scroll').last().css 'padding-bottom', 0
if(staticPanels.length is 1)
$('.static').first().addClass('scroll').removeClass('static').css {
'position': 'relative'
'padding-bottom': 0
}
else
staticPanels.first().addClass('scroll').removeClass('static').css {
'position': 'relative'
}
else
#up
if($element.offset().top > position)
scroll = $('.scroll')
if(scroll.length > 1)
scroll.last().addClass('static').removeClass('scroll').css 'padding-bottom', $(window).height()
$('.static').first().css 'position', 'fixed'
lastPosition = position
return
$(window).resize ->
clearTimeout resizeDelay
resizeDelay = setTimeout(self.resize(), self.options.resizeDelay)
return
return self.outerContainer
slide: (id) ->
self = @
curPos = $(window).scrollTop()
dest = self.locations[id]
time = (Math.abs(curPos - dest) / self.options.speed) * 1000
$('html,body').animate {
scrollTop: dest
}, time
return self.outerContainer
resize: ->
self = @
self.setHeights()
setTimeout (->
self.setOffsets()
), 100
return self.outerContainer
setHeights: ->
self = @
# Set minimum heights for panels to match browser height
self.innerContainers.css('min-height', $(window).height())
self.outerContainer.css('min-height', self.getOuterHeight())
return self.outerContainer
setOffsets: ->
self = @
# Get top offsets fore each panel. This will be used
# for scrolling between panels
self.locations = {}
startingPos = 0
self.panels.each ->
height = $(@).find(self.options.containerSelector).outerHeight()
startingPos += height
self.locations['#'+$(@).attr('id')] = startingPos - height
return
return self.outerContainer
getOuterHeight: ->
self = @
height = 0
self.innerContainers.each ->
height += $(@).outerHeight()
return
return height
}
$.fn.panelize = () ->
if not $.fn.panelize.instance?
$.fn.panelize.instance = Object.create(Panelize)
if typeof arguments[0] is 'object' or arguments[0] is undefined
return $.fn.panelize.instance.init(@, arguments[0])
else if arguments[0] is 'resize'
return $.fn.panelize.instance.resize()
else if arguments[0] is 'slide' and arguments[1]?
return $.fn.panelize.instance.slide(arguments[1])
else
$.error('Method '+method+' does not exists on jQuery.panelize');
$.fn.panelize.options = {
containerSelector: null
speed: 1000
startZ: 1000
zStep: 50
resizeDelay: 300
}
) jQuery, window, document
$(document).ready ->
$panels = $('.panelize').panelize({
containerSelector: 'article'
speed: 2000
startZ: 1000
zStep: 50
})
$nav = $('#header a')
$nav.click (e) ->
e.preventDefault()
$nav.removeClass('active')
$(@).addClass('active')
$panels.panelize('slide', $(@).attr('href'))
Also see: Tab Triggers