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.
<div class="wrap">
<div class="before-editor">
<h1>WordPress editor scroll behavior idea</h1>
<p class="byline">by Mark Jaquith</p>
<p>Here's the idea.</p>
<p>Everything above the post editor scrolls normally.</p>
<p>The entire post is shown in the editor — no scroll bars there.</p>
<p>The post editor's bottom bar is pinned if the whole post can't be shown.</p>
<p>When the post editor's top bar is about to scroll off the page, it pins.</p>
<p>When the bottom of the post is reached, the bottom bar unpins, and you have access to the meta boxes below.</p>
<p>It's just normal page scrolling, with pinning of the top and bottom bars at appropriate times.</p>
<p><b>Todo:</b> "jump to bottom" and "jump to top" contextual hover buttons for long posts.</p>
<p><input class="title" type="text" value="Post Title" /></p>
</div>
<div class="editor-wrap">
<div class="bar-top-placeholder">
<div class="bar bar-top">
<button><b>B</b></button>
<button><i>i</i></button>
<button><u>a</u></button>
<button>etc…</buton>
</div>
</div>
<div class="editor" contentEditable="true">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non massa dolor. Donec nec nibh fringilla, hendrerit urna ac, rutrum nunc. Vestibulum elementum tellus sapien, non placerat nulla mollis non. Pellentesque sit amet massa ac nulla mollis egestas et in mauris. Vestibulum posuere libero posuere mauris tristique, ac pretium urna tristique. Integer non enim a quam gravida pharetra. Interdum et malesuada fames ac ante ipsum primis in faucibus. Duis et mattis lorem, quis convallis nulla. Nunc tortor ipsum, rutrum at sagittis vel, vulputate a sem. Cras nec lacus vitae nisl varius malesuada quis sed tortor. Integer eget dolor sit amet nisl lacinia ultrices. Vestibulum ac nulla ultricies, tempor leo ut, tincidunt orci. Etiam eu augue consectetur, sodales lorem eleifend, pellentesque dui. Nam porta tellus non ornare rhoncus. Donec euismod erat sit amet nisi laoreet, ut euismod mi pulvinar.</p>
<p>Fusce non commodo ante, non tempus tellus. Etiam non tellus non mauris semper vestibulum ut et ligula. Vivamus sit amet feugiat enim. Curabitur congue posuere est vel pulvinar. Duis nec leo non sapien sagittis dapibus. Aenean faucibus erat sem, sed blandit neque placerat vitae. Suspendisse tincidunt erat tortor, nec pretium urna convallis quis. Mauris faucibus sapien orci, sit amet viverra ante cursus non. Nam scelerisque justo ut orci suscipit, vitae ornare turpis faucibus. Fusce elementum pharetra pulvinar. Nulla euismod tristique justo. Aliquam pretium eros eu diam vulputate, nec laoreet leo bibendum. Vestibulum libero odio, vehicula eget arcu ut, aliquet ullamcorper ante. Mauris et lectus dignissim justo viverra congue. Vivamus molestie consequat odio a dignissim. Nunc interdum magna et sagittis egestas.</p>
<p>Donec quam mauris, ullamcorper tempus purus id, accumsan faucibus arcu. Nam nulla augue, suscipit id eleifend et, facilisis eget dui. Proin sit amet ultrices risus, nec posuere odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam feugiat tellus a tellus commodo malesuada. Vivamus vitae mauris ac lectus pellentesque porta eu eget diam. Vivamus varius viverra arcu, sed ultrices mi. Proin luctus tellus varius justo ullamcorper, malesuada sollicitudin diam porta. Aliquam erat volutpat. Nulla facilisi. Quisque lacinia augue sit amet mi imperdiet tincidunt. Nunc porttitor vulputate malesuada. Quisque augue diam, gravida et nulla ut, fringilla lacinia nisl. Nulla in sodales magna, at euismod nulla.</p>
<p>Proin congue pellentesque nibh a porttitor. Morbi molestie in sem dignissim convallis. Sed pulvinar tincidunt massa eget sollicitudin. Nulla et cursus lacus. Phasellus augue tortor, cursus vitae tortor quis, vehicula tincidunt leo. Fusce iaculis quam vel quam elementum eleifend. Quisque eleifend rutrum purus, vel egestas tellus gravida ac. Ut eu dapibus dolor, vel tristique leo. Maecenas sagittis pretium mi eget vehicula. Donec pharetra mattis nulla sed condimentum. Fusce posuere lorem sed facilisis hendrerit. Sed sollicitudin velit ac vulputate luctus. Duis porta sed mauris quis vestibulum. Fusce justo ipsum, dignissim quis lacus vitae, egestas suscipit augue.</p>
<p>Phasellus malesuada sem id pellentesque adipiscing. Proin mattis adipiscing nulla adipiscing tincidunt. Ut aliquam accumsan eros eget iaculis. Nulla quis velit ultrices elit tincidunt luctus ut aliquet orci. Sed semper nisi nunc, tincidunt molestie nunc congue nec. Suspendisse at dolor ligula. Maecenas mollis hendrerit ipsum, pharetra egestas eros tempor ut. Nam malesuada eros ornare eros hendrerit, sed dignissim ipsum iaculis. Suspendisse convallis, nulla vel fermentum aliquet, metus erat dignissim odio, at faucibus augue massa nec eros. Duis imperdiet ante id massa auctor rutrum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec non massa dolor. Donec nec nibh fringilla, hendrerit urna ac, rutrum nunc. Vestibulum elementum tellus sapien, non placerat nulla mollis non. Pellentesque sit amet massa ac nulla mollis egestas et in mauris. Vestibulum posuere libero posuere mauris tristique, ac pretium urna tristique. Integer non enim a quam gravida pharetra. Interdum et malesuada fames ac ante ipsum primis in faucibus. Duis et mattis lorem, quis convallis nulla. Nunc tortor ipsum, rutrum at sagittis vel, vulputate a sem. Cras nec lacus vitae nisl varius malesuada quis sed tortor. Integer eget dolor sit amet nisl lacinia ultrices. Vestibulum ac nulla ultricies, tempor leo ut, tincidunt orci. Etiam eu augue consectetur, sodales lorem eleifend, pellentesque dui. Nam porta tellus non ornare rhoncus. Donec euismod erat sit amet nisi laoreet, ut euismod mi pulvinar.</p>
<p>Fusce non commodo ante, non tempus tellus. Etiam non tellus non mauris semper vestibulum ut et ligula. Vivamus sit amet feugiat enim. Curabitur congue posuere est vel pulvinar. Duis nec leo non sapien sagittis dapibus. Aenean faucibus erat sem, sed blandit neque placerat vitae. Suspendisse tincidunt erat tortor, nec pretium urna convallis quis. Mauris faucibus sapien orci, sit amet viverra ante cursus non. Nam scelerisque justo ut orci suscipit, vitae ornare turpis faucibus. Fusce elementum pharetra pulvinar. Nulla euismod tristique justo. Aliquam pretium eros eu diam vulputate, nec laoreet leo bibendum. Vestibulum libero odio, vehicula eget arcu ut, aliquet ullamcorper ante. Mauris et lectus dignissim justo viverra congue. Vivamus molestie consequat odio a dignissim. Nunc interdum magna et sagittis egestas.</p>
<p>Donec quam mauris, ullamcorper tempus purus id, accumsan faucibus arcu. Nam nulla augue, suscipit id eleifend et, facilisis eget dui. Proin sit amet ultrices risus, nec posuere odio. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. Nam feugiat tellus a tellus commodo malesuada. Vivamus vitae mauris ac lectus pellentesque porta eu eget diam. Vivamus varius viverra arcu, sed ultrices mi. Proin luctus tellus varius justo ullamcorper, malesuada sollicitudin diam porta. Aliquam erat volutpat. Nulla facilisi. Quisque lacinia augue sit amet mi imperdiet tincidunt. Nunc porttitor vulputate malesuada. Quisque augue diam, gravida et nulla ut, fringilla lacinia nisl. Nulla in sodales magna, at euismod nulla.</p>
<p>Proin congue pellentesque nibh a porttitor. Morbi molestie in sem dignissim convallis. Sed pulvinar tincidunt massa eget sollicitudin. Nulla et cursus lacus. Phasellus augue tortor, cursus vitae tortor quis, vehicula tincidunt leo. Fusce iaculis quam vel quam elementum eleifend. Quisque eleifend rutrum purus, vel egestas tellus gravida ac. Ut eu dapibus dolor, vel tristique leo. Maecenas sagittis pretium mi eget vehicula. Donec pharetra mattis nulla sed condimentum. Fusce posuere lorem sed facilisis hendrerit. Sed sollicitudin velit ac vulputate luctus. Duis porta sed mauris quis vestibulum. Fusce justo ipsum, dignissim quis lacus vitae, egestas suscipit augue.</p>
</div>
<div class="bar bar-bottom">
<span class="wc">Word Count: 12345</span>
</div>
</div>
<div class="after-editor">
<meta-box>
<p><strong>Meta Box</strong></p>
<p>Proin congue pellentesque nibh a porttitor. Morbi molestie in sem dignissim convallis. Sed pulvinar tincidunt massa eget sollicitudin. Nulla et cursus lacus. Phasellus augue tortor, cursus vitae tortor quis, vehicula tincidunt leo. Fusce iaculis quam vel quam elementum eleifend. Quisque eleifend rutrum purus, vel egestas tellus gravida ac. Ut eu dapibus dolor, vel tristique leo. Maecenas sagittis pretium mi eget vehicula. Donec pharetra mattis nulla sed condimentum. Fusce posuere lorem sed facilisis hendrerit. Sed sollicitudin velit ac vulputate luctus. Duis porta sed mauris quis vestibulum. Fusce justo ipsum, dignissim quis lacus vitae, egestas suscipit augue.</p>
</meta-box>
<meta-box>
<p><strong>Meta Box</strong></p>
<p>Proin congue pellentesque nibh a porttitor. Morbi molestie in sem dignissim convallis. Sed pulvinar tincidunt massa eget sollicitudin. Nulla et cursus lacus. Phasellus augue tortor, cursus vitae tortor quis, vehicula tincidunt leo. Fusce iaculis quam vel quam elementum eleifend. Quisque eleifend rutrum purus, vel egestas tellus gravida ac. Ut eu dapibus dolor, vel tristique leo. Maecenas sagittis pretium mi eget vehicula. Donec pharetra mattis nulla sed condimentum. Fusce posuere lorem sed facilisis hendrerit. Sed sollicitudin velit ac vulputate luctus. Duis porta sed mauris quis vestibulum. Fusce justo ipsum, dignissim quis lacus vitae, egestas suscipit augue.</p>
</meta-box>
</div>
@import compass
*
box-sizing: border-box
body
font-family: Helvetica
h1
margin: 0
p.byline
margin-top: 0
.title
font-size: 22px
width: 100%
&:focus
outline: none
.bar
width: 100%
padding: 5px
border: 1px solid #ccc
background: rgba( 245, 245, 245, 0.95 )
.editor
width: 100%
border: 1px solid #ccc
border-width: 0 1px
padding: 5px
line-height: 1.6em
font-size: 18px
&:focus
outline: none
meta-box
display: block
border: 1px solid #ccc
margin: 20px 0
padding: 5px
background: #eee
jQuery ($) ->
$win = $ window
$top = $ '.bar-top'
$bot = $ '.bar-bottom'
$ed = $ '.editor'
$topPlaceholder = $ '.bar-top-placeholder'
fixedTop = no
fixedBottom = no
adjust = ->
winPos = $win.scrollTop()
topPos = $top.offset().top
topHeight = $top.outerHeight()
botPos = $bot.offset().top
botHeight = $bot.outerHeight()
edPos = $ed.offset().top
edHeight = $ed.outerHeight()
winHeight = $win.height()
# Maybe adjust the top bar
if winPos >= topPos and not fixedTop
fixedTop = yes
$topPlaceholder.css
height: $top.outerHeight() + 'px'
$top.css
position: 'fixed'
top: '0'
else if winPos < (edPos - topHeight) and fixedTop
fixedTop = no
$topPlaceholder.css
height: 'auto'
$top.css
position: 'static'
top: 'auto'
# Maybe adjust the bottom bar
if (winPos + winHeight) <= (edPos + edHeight + botHeight) and not fixedBottom
fixedBottom = yes
$bot.css
position: 'fixed'
bottom: '0'
else if (winPos + winHeight) > (edPos + edHeight + botHeight) and fixedBottom
fixedBottom = no
$bot.css
position: 'static'
bottom: 'auto'
adjust()
$win.scroll adjust
Also see: Tab Triggers