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.
<div id="list"></div>
<div id="posts">
<div class="post-wrapper">
<div class="close-posts">X</div>
<div class="post">
<div class="post-inner">
<span class="typography">Fira Sans</span>
<span class="typ-msg">I selected this font for the body text on MarsX's website.</span>
<h2 className="post-title">Jordan Smith sings "The Grinch"</h2>
<iframe width="560" height="315" src="https://www.youtube.com/embed/l5Y0lVM-44k" frameborder="0" allowfullscreen></iframe>
<div className="excerpt">I've always enjoyed this song - and this is a great rendition of it.</div>
<div className="entry-meta">
<a className="button read-more" href="#">Read More »</a>
</div>
</div>
</div>
</div>
</div>
/**
* Variables
*/
$color__light_blue: #CAE4F2;
$color__dark_blue: #2A6FB0; /* 42, 111, 176 */
$color__dark_blue_alpha: rgba(42,111,176,0.3);
$color__dark_blue_dark_alpha: rgba(42,111,176,0.8);
$color__light_green: #65C0A5;
$color__dark_green: #0B8972; /* #35a66f
*/
$color__dark_green_alpha: #6DB8AA;
$color__light_red: #F17259;
$color__light_red_alpha: #F38E7A;
$color__dark_red: #9D1313;
$color__dark_red_alpha: rgba(157,19,19,0.8);
$font_stack__body: 'Nunito', 'Quicksand', 'Valero Round', sans-serif;
$font_stack__headings: 'Sonsie One', cursive;
$section_height: 100vh;
$section_width: calc( 100vw + 17px );
$post_width: 670px;
* {
position: relative;
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-size: 16px;
background: $color__light_blue;
font-family: $font_stack__body;
font-weight: 100;
letter-spacing: -0.2px;
line-height: 1.6;
}
h1, h2, h3, h4, h5, h6 {
font-family: $font_stack__headings;
}
/**
* React Posts
*/
#posts {
margin: 0 auto;
position: absolute;
top: 0;
background-color: $color__dark_blue_dark_alpha;
// Smaller
// background-image:
// repeating-linear-gradient(120deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 60px),
// repeating-linear-gradient(60deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 1px, transparent 1px, transparent 60px),
// linear-gradient(60deg, rgba(0,0,0,.05) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.05) 75%, rgba(0,0,0,.05)),
// linear-gradient(120deg, rgba(0,0,0,.05) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.05) 75%, rgba(0,0,0,.05));
// background-size: 70px 120px;
// Larger
background-image:
repeating-linear-gradient(120deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 2px, transparent 2px, transparent 120px),
repeating-linear-gradient(60deg, rgba(255,255,255,.1), rgba(255,255,255,.1) 2px, transparent 2px, transparent 120px),
linear-gradient(60deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1)),
linear-gradient(120deg, rgba(0,0,0,.1) 25%, transparent 25%, transparent 75%, rgba(0,0,0,.1) 75%, rgba(0,0,0,.1));
background-size: 138px 240px;
z-index: 1000;
transition: 0.3s ease-in all;
}
#posts .close-posts {
font-size: 3em;
font-weight: 100;
position: absolute;
top: 10px;
right: 40px;
color: $color__light_blue;
text-shadow: 1px 1px 3px $color__dark_blue;
}
#posts .close-posts:hover {
cursor: pointer;
text-shadow: 2px 2px 5px $color__dark_blue;
opacity: 0.8;
}
#posts .post-controls {
position: absolute;
top: 50%;
transform: translateY(-50%);
text-align: center;
}
#posts .post-prev,
#posts .post-next {
color: white;
background: $color__dark_blue;
width: 30px;
height: 50px;
display: block;
position: absolute;
transform: translateY(-50%);
padding: 0 10px;
left: -20px;
z-index: 10001;
}
#posts .post-next {
left: 580px;
}
#posts .post {
width: $post_width;
box-sizing: border-box;
background: white;
margin: 50vh 50vw;
transform: translate(-50%, -50%);
display: inline-block;
padding: 5px;
display: hidden;
box-shadow: 2px 2px 10px $color__dark_blue;
}
#post iframe {
max-width: 100%;
position: absolute;
}
#posts .post-inner {
padding: 2em 3em 1em;
border: 2px solid $color__dark_blue_alpha;
width: 100%;
position: relative;
}
#posts .post:hover .post-inner {
border: 2px solid $color__dark_blue;
}
#posts .post-title a {
color: black;
text-decoration: none;
border: 0;
padding-bottom: 2em;
}
#posts .excerpt {
padding: 0.5em 0 1em;
}
#posts .entry-meta {
padding: 0 0 1.5em;
border: 0;
text-align: center;
}
#posts .author-wrap {
border: 0;
color: $color__dark_blue;
}
#posts .avatar {
padding-right: 0.5em;
}
#posts .button {
border: 0;
background: $color__dark_blue_dark_alpha;
color: white;
display: inline-block;
margin: 0 auto;
padding: 0.5em 1em;
border-radius: 5px;
opacity: 0.6;
}
#posts .button:hover {
background: $color__dark_blue;
opacity: 1;
}
/**
* Stocking Component
*/
.stocking-wrap,
.padding,
.ankle,
.soul,
.heel,
.toe,
.date {
position: absolute;
}
.stocking-wrap {
width: 200px;
height: 300px;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
// transform: scale(0.5);
}
.stocking-wrap-inner {
transform: rotate(-10deg);
}
.padding {
width: 200px;
height: 100px;
background: white;
border-radius: 30px;
}
.padding:after {
box-sizing: border-box;
width: 204px;
height: 104px;
content: '';
display: block;
position: absolute;
top: -2px;
left: -2px;
border-width: 3px;
border-style: dotted;
border-color: white;
border-image-source: url('https://gist.githubusercontent.com/jekkilekki/a2d14f2f9cdbfbfec267dca9204f6b1c/raw/b85ea3e59642f173dd3efce54a8d3d6fc2d8f775/dot-border.svg');
border-image-slice: 33% 33%;
border-image-repeat: round;
border-radius: 30px;
}
.ankle {
height: 130px;
width: 140px;
background: $color__dark_green;
z-index: -1;
left: 30px;
top: 100px;
}
.ankle:before,
.ankle:after {
content: "";
display: block;
position: absolute;
top: 0px;
width: 100%;
height: 10px;
background:
linear-gradient(
45deg, transparent 33.333%,
$color__light_green 33.333%, $color__light_green 66.667%,
transparent 66.667%
),
linear-gradient(
-45deg, transparent 33.333%,
$color__light_green 33.333%, $color__light_green 66.667%,
transparent 66.667%
);
background-size: 20px 40px;
border-color: black;
top: 40px;
width: 140px;
}
.ankle:after {
top: 20px;
}
.soul {
height: 120px;
width: 120px;
background: $color__dark_green;
z-index: -1;
top: 200px;
left: 0px;
transform: rotate(-30deg);
}
.heel {
height: 90px;
width: 90px;
background: $color__light_red;
top: 202px;
right: 17px;
border-radius: 100px 0px 120px 0px;
transform: rotate(-15deg);
}
.toe {
height: 121px;
width: 70px;
background: $color__light_red;
top: 240px;
left: -45px;
transform: rotate(-30deg);
border-radius: 170px 40px 40px 170px;
}
.date {
position: absolute;
top: 45px;
left: 50%;
transform: translate(-50%,-40%);
color: white;
text-align: center;
font-size: 2em;
line-height: 2em;
letter-spacing: -2px;
z-index: 5;
background: $color__light_red_alpha;
width: 70px;
height: 70px;
border-radius: 50%;
padding: 5px;
// box-shadow: 2px 2px 5px rgba(60,60,60,1);
}
.date:before,
.date:after {
content: '';
display: block;
position: absolute;
background: $color__light_red;
width: 20px;
height: 20px;
border-radius: 50%;
top: 25px;
right: 85px;
opacity: 0.5;
}
.date:after {
left: 85px;
right: auto;
}
$.fn.snow();
var date = new Date();
date = date.getDate();
var Interface = React.createClass({
getInitialState: function() {
return {
title: ['Naughty', 'Nice', 'Wish'],
titleId: 1,
show: false,
source: '',
date: date,
data: [
{
"childName": "Aaron",
"status": 0,
"giftChoice": "New Job",
"birthday": "1999-12-12",
"notes": "Last name Snowberger"
},
{
"childName": "Sarah",
"status": 1,
"giftChoice": "Wool Coat",
"birthday": "1989-07-29",
"notes": "Korean name KEY"
},
{
"childName": "Isaac",
"status": 1,
"giftChoice": "Legos",
"birthday": "2004-04-04",
"notes": "Love Legos, like, really, LOVES Legos"
},
{
"childName": "Jenna",
"status": 1,
"giftChoice": "Frozen 2",
"birthday": "2010-10-10",
"notes": "Wants to time travel to the future to see Frozen 2"
}
],
advent: [
{ // Dec 1
"font": {
"typeface": "Sonsie One",
"googleFont": true,
"url": "",
"fontMsg": "Selected for the large, stylized numerals."
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 2
"font": {
"typeface": "Varela Round",
"googleFont": true,
"url": "",
"fontMsg": 'This is the ONLY Google Font with "Round" in its name.'
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 3
"font": {
"typeface": "Averia Serif Libre",
"googleFont": true,
"url": "",
"fontMsg": "A great, rounded, old-style, Christmas-y serif font."
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 4
"font": {
"typeface": "Quicksand",
"googleFont": true,
"url": "",
"fontMsg": "A thin sans-serif with rounded terminals."
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 5
"font": {
"typeface": "Nunito",
"googleFont": true,
"url": "",
"fontMsg": "A nicer sans-serif with rounded terminals. (Also, the body font on <a href='http://poststatus.com'>Post Status</a>.)"
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 6
"font": {
"typeface": "Volkhov",
"googleFont": true,
"url": "",
"fontMsg": "A beautiful serif I recently used for the headings on my <a href='http://wordpress.org/themes/jkl'>first WordPress theme on the .org repository</a>."
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 7
"font": {
"typeface": "Source Sans Pro",
"googleFont": true,
"url": "",
"fontMsg": "The sans-serif font I selected for the body on my <a href='http://wordpress.org/themes/jkl'>first WordPress theme on the .org repository</a>."
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 8
"font": {
"typeface": "Source Code Pro",
"googleFont": true,
"url": "",
"fontMsg": "The monospace font I selected for <code> tags on my <a href='http://wordpress.org/themes/jkl'>first WordPress theme on the .org repository</a>."
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 9
"font": {
"typeface": "Font Awesome",
"googleFont": false,
"url": "",
"fontMsg": "Simply, Awesome. Obviously I love Font Awesome - and backed <a href='http://kickstarter.com'>Font Awesome 5.0</a>!"
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 10
"font": {
"typeface": "Merriweather",
"googleFont": true,
"url": "",
"fontMsg": "This is one of the most beautiful serif fonts I've seen in recent years. I used it in a book I wrote."
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 11
"font": {
"typeface": "Montserrat",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 12
"font": {
"typeface": "Playfair Display",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 13
"font": {
"typeface": "Oswald",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 14
"font": {
"typeface": "Play",
"googleFont": true,
"url": "",
"fontMsg": "A font I selected for a new logo (MarsX) I designed. (They wanted something a little like SpaceX.)"
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 15
"font": {
"typeface": "Fira Sans",
"googleFont": true,
"url": "",
"fontMsg": "I selected this font for the body text on MarsX's website."
},
"video": {
"provider": "youtube",
"videoId": "l5Y0lVM-44k",
"videoTitle": 'Jordan Smith sings "The Grinch"',
"videoMsg": "I've always enjoyed this song - and this is a great rendition of it."
}
},
{ // Dec 16
"font": {
"typeface": "Julius Sans One",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 17
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 18
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 19
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 20
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 21
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 22
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 23
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": ""
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 24
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": "Since it's my birthday today..."
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
{ // Dec 25
"font": {
"typeface": "",
"googleFont": true,
"url": "",
"fontMsg": "The Christmas font!"
},
"video": {
"provider": "youtube",
"videoId": "",
"videoTitle": "",
"videoMsg": ""
}
},
]
}
},
componentDidMount: function() {
this.serverRequest = axios.get(this.props.source).then(function(result){
var tempAdvent = result;
this.setState({
advent: tempAdvent
});
}.bind(this));
alert(advent)
},
componentWillUnmount: function() {
console.log("aborting")
this.serverRequest.abort();
},
showList: function() {
var whose;
if( this.state.show ) {
whose = "Santa's";
}
var styleList = {
display: this.state.show ? 'block':'none',
color: 'red'
}
var filteredList = this.state.data;
filteredList = filteredList.map(function(item, index){
return (
<ul className="item-list">
<li className="child-item" key={index}>
<div className="child-info">
<div className="child-head">
<span className="child-name">{this.state.data[index].childName}</span>
<span className="birthday">{this.state.data[index].birthday}</span>
</div>
<div className="gift-choice">{this.state.data[index].giftChoice}</div>
<div className="notes">{this.state.data[index].notes}</div>
</div>
</li>
</ul>
)
}.bind(this)); // Must bind to this
},
showPost: function() {
var today = this.state.date;
console.log(today);
var postId = "day" + date;
var videoSrc = "https://www.youtube.com/embed/" + this.state.advent[today].video.videoId;
return (
<div className="post-wrapper">
<div className="close-posts">X</div>
<div id="stocking"></div>
<div id={postId} className="post">
<div className="post-inner">
<span className="typography">{this.state.advent[today].font.typeface}</span>
<h2 className="post-title">{this.state.advent[today].video.videoTitle}</h2>
<iframe width="560" height="315" src={videoSrc} frameborder="0" allowfullscreen></iframe>
<div className="excerpt">{this.state.advent[today].video.videoMsg}</div>
<div className="entry-meta">
<a className="button read-more" href="#">Read More »</a>
</div>
</div>
</div>
</div>
)
},
render: function() {
return (
this.state.show ? this.showPost() : this.showList()
)
}
});
/* Date stuff */
var today = new Date();
/**
* Stocking Component
*/
var Stocking = React.createClass({
render: function() {
return (
<div className="stocking-wrap">
<div className="stocking-wrap-inner">
<div className="padding"></div>
<div className="ankle"></div>
<div className="soul"></div>
<span className="heel"></span>
<span className="toe"></span>
<h1 className="date">{today.getDate()}</h1>
</div>
</div>
)
}
});
ReactDOM.render(
<Interface source="https://rawgit.com/jekkilekki/53794d3481848cde2e3ded8ba527ca0e/raw/a5e66518ede77ea748d47c9d75dfb8e4f11718fa/05-react-christmas-playlist.json"/>,
document.getElementById('list')
);
ReactDOM.render(
<Stocking/>,
document.getElementById('stocking')
);
Also see: Tab Triggers