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 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.
.container
.contacts
.buttons
button.new-message.fa-envelope-o
button.search.fa-search
ul
- for i in 1..4
li
.messages
ul
- for i in ['Is this the real life?', 'Is this just fantasy?', 'Caught in a landslide', 'No escape from reality.', 'Open your eyes', 'Look up to the skies and see', 'I\'m just a poor boy, I need no sympathy', 'Because I\'m easy come, easy go', 'Little high, little low', 'Anyway the wind blows doesn\'t really matter to me, to me.', 'Mama, just killed a man', 'Put a gun against his head', 'Pulled my trigger, now he\'s dead.', 'Mama, life had just begun', 'But now I\'ve gone and thrown it all away.', 'Mama, ooh', 'Didn\'t mean to make you cry', 'If I\'m not back again this time tomorrow', 'Carry on, carry on as if nothing really matters.', 'Too late, my time has come', 'Sent shivers down my spine', 'Body\'s aching all the time.', 'Goodbye, everybody, I\'ve got to go', 'Gotta leave you all behind and face the truth.', 'Mama, ooh (anyway the wind blows)', 'I don\'t wanna die', 'I sometimes wish I\'d never been born at all.', 'I see a little silhouetto of a man', 'Scaramouche, Scaramouche, will you do the Fandango?', 'Thunderbolt and lightning', 'Very, very frightening me.', '(Galileo) Galileo.', '(Galileo) Galileo', 'Galileo Figaro', 'Magnifico.', 'I\'m just a poor boy, nobody loves me.', 'He\'s just a poor boy from a poor family', 'Spare him his life from this monstrosity.', 'Easy come, easy go, will you let me go?', 'Bismillah! No, we will not let you go. (Let him go!)', 'Bismillah! We will not let you go. (Let him go!)', 'Bismillah! We will not let you go. (Let me go!)', 'Will not let you go. (Let me go!)', 'Never, never let you go', 'Never let me go, oh.', 'No, no, no, no, no, no, no.', 'Oh, mama mia, mama mia (Mama mia, let me go.)', 'Beelzebub has a devil put aside for me, for me, for me.', 'So you think you can stone me and spit in my eye?', 'So you think you can love me and leave me to die?', 'Oh, baby, can\'t do this to me, baby', 'Just gotta get out, just gotta get right outta here.', '(Oh, yeah, oh yeah)', 'Nothing really matters', 'Anyone can see', 'Nothing really matters', 'Nothing really matters to me.', 'Anyway the wind blows.']
li #{i}
.stack-wrap
.form
.form-inner
button ✚
=clearfix
&::after
content: ' '
display: block
clear: both
height: 0
visibility: hidden
font-size: 0
html, body, .container
height: 100%
overflow: hidden
body
margin: 0
.container
width: 100%
display: flex
flex-flow: column wrap
.contacts
flex-basis: 100%
width: 240px
overflow-y: hidden
background-color: skyblue
//background-image: linear-gradient(-45deg, rgba(0, 0, 0, 0) 45%, whitesmoke 49%, whitesmoke 51%, rgba(0, 0, 0, 0) 55%)
background-size: 6px 6px
.buttons
margin-right: 6px
+clearfix
button
float: right
height: 30px
width: 30px
margin: 8px 6px 12px
padding: 0
border: 0
border-radius: 2px
font-family: Fontawesome
color: skyblue
background: whitesmoke
cursor: pointer
ul
width: calc(100% - 12px * 2)
margin: 0 12px
padding: 0
list-style: none
li
position: relative
width: 100%
height: 84px
margin-bottom: 12px
border-radius: 2px
background: whitesmoke
&::before
content: ''
position: absolute
top: 18px
left: 12px
height: 48px
width: 48px
border-radius: 30px
background: gainsboro
&::after
content: '✖'
position: absolute
top: -8px
right: -8px
overflow: hidden
height: 0
line-height: 26px
width: 0
margin: 12px
border-radius: 12px
text-align: center
color: whitesmoke
background: tomato
cursor: pointer
transition: height 0.1s, width 0.1s, margin 0.1s
&:hover
&::after
height: 24px
width: 24px
margin: 0
.messages, .form
width: calc(100% - 240px)
.messages
flex: 1 1px
background: tomato
overflow-y: scroll
ul
list-style: none
margin: 0
padding: 36px
+clearfix
li
float: left
clear: both
line-height: 1.4em
max-width: 224px
margin: 12px
padding: 0.7em 16px
border-radius: 18px
font-family: sans-serif
color: whitesmoke
background: skyblue
&:nth-child(odd)
border-bottom-left-radius: 2px
&:nth-child(even)
float: right
border-bottom-right-radius: 2px
.form
background: gainsboro
.form-inner
height: 60px
width: calc(100% - 12px * 2) // ugh just let me use border-box
margin: 12px
border-radius: 2px
background: whitesmoke
button
float: right
height: 100%
width: 60px
padding: 1px0
border: 0
border-radius: 0 2px 2px 0
font: 30px/60px sans-serif
color: whitesmoke
background: skyblue
cursor: pointer
.small-screen
&.container
align-content: center
.stack-wrap
position: relative
flex: 1 1px
div
position: absolute
top: 0
bottom: 0
.contacts
left: 0
width: 66px
.buttons
display: none //TODO
ul
width: 100%
margin: 0
li
height: 66px
margin: 0
background: transparent
&::before
top: 9px
left: 9px
background: whitesmoke
&::after
top: -2px
right: 2px
.messages
left: 66px
right: 0
width: auto
.form
width: 100%
!function () {
var container = document.querySelector('.container');
var stackWrap = document.querySelector('.stack-wrap');
var contacts = document.querySelector('.contacts');
var messages = document.querySelector('.messages');
var small, limiter;
function relayout () {
var width = window.innerWidth;
console.log(width, small);
if (!small && width < 600) {
small = true;
container.classList.add('small-screen');
stackWrap.appendChild(contacts);
stackWrap.appendChild(messages);
} else if (small && width >= 600) {
small = false;
container.classList.remove('small-screen');
container.insertBefore(contacts, stackWrap);
container.insertBefore(messages, stackWrap);
}
}
window.addEventListener('resize', function () {
clearTimeout(limiter);
limiter = setTimeout(relayout, 100);
});
relayout();
}();
Also see: Tab Triggers