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="container">
<header class="text-center">
<div class="title-box">
<h1>
<small>The </small>Office
<img src="http://blacknerdproblems.com/wp-content/uploads/2015/06/88892.jpg" class="img-responsive logo" alt="The Office logo">
</h1>
</div>
</header>
</div>
<div class="container">
<div class="corkboard-border">
<div class="corkboard">
<h2 class="text-center"><small class="lead">quote generator</small></h2>
<div class="row">
<div class="col-sm-3 col-sm-push-1">
<a href="javascript:void(0);" role="button" id="button">
<div class="post-it">
That's what she said
</div>
</a>
</div>
<div class="col-sm-8 col-sm-push-1">
<div class="scrap">
<div class="wrapper" id="paper">
<img class="img-responsive" src="https://miund.files.wordpress.com/2008/01/logo.jpg" alt="Dunder Mifflin Logo">
<p id="quote"></p>
<p id="character" class="text-right"></p>
<div id="twtbox"></div>
</div>
</div>
</div>
</div>
</div> <!-- /.corkboard -->
</div> <!-- /.corkboard-border -->
</div> <!-- /.container -->
<!-- jQuery & JS -->
<script>
window.twttr = (function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0],
t = window.twttr || {};
if (d.getElementById(id)) return t;
js = d.createElement(s);
js.id = id;
js.src = "https://platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js, fjs);
t._e = [];
t.ready = function(f) {
t._e.push(f);
};
return t;
}
(document, "script", "twitter-wjs"));
</script>
@import url(https://fonts.googleapis.com/css?family=Architects+Daughter);
body {
font-family: Courier, Monospace;
font-size: 18px;
background: url('https://c2.staticflickr.com/6/5138/5443103160_023abd38a2_b.jpg');
background-size: cover;
background-attachment: fixed;
}
::selection {
background: #f7f776;
}
.corkboard-border {
padding: 1.5vw;
background: #a15e33;
background: radial-gradient(#a15e33, #3f2514);
box-shadow: 0 0 10px #000000;
}
.corkboard {
background: #B08E5E;
background: url("https://d13yacurqjgara.cloudfront.net/users/2437/screenshots/1671078/iphoto_corkboard_1x.png");
box-shadow: inset 0 0 10px #000000;
padding: 30px 20px 50px 20px;
position: relative;
}
#character {
font-family: 'Architects Daughter';
font-size: 1.7em;
}
.title-box {
display: inline-block;
background: #000;
padding: 0 2em;
border-radius: 10px;
box-shadow: 2px 3px 10px -1px rgba(0,0,0,0.75);
position: relative;
z-index: 1000;
}
h1 {
font-size: 3em;
}
h1,
h1 small {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-weight: bold;
color: #fff;
}
.logo {
display: inline-block;
width: 100px;
height: auto;
}
header {
margin: 50px auto;
}
h2 {
transform: rotate(-1deg);
margin-bottom: 30px
}
h2 .lead {
padding: 10px 3em;
color: #354E8D;
background-color: #f7f776;
border-top-right-radius: 10%;
border-bottom-left-radius: 10%;
box-shadow: 0px 1px 6px -1px rgba(0,0,0,0.5);
}
.post-it {
font-family: 'Architects Daughter', Helvetica, Arial, sans-serif;
font-size: 1.3em;
padding: 10px;
color: #000;
background: #ffb7b7;
padding: 30px 15px;
height: 155px;
max-width: 250px;
border-bottom-left-radius: 3%;
border-bottom-right-radius: 2%;
box-shadow: 0px 3px 10px -1px rgba(0,0,0,0.75);
transform: rotate(-2deg);
}
.post-it:hover {
background-color: #ffa5a5;
}
.post-it:active {
transform: scale3d(1.05, 1.05, 1.05);
}
a:hover {
text-decoration: none;
}
.wrapper {
background-color: #fff;
padding: 15px;
position: relative;
}
.wrapper img {
position: absolute;
width: 100px;
height: auto;
}
.scrap {
background-color: #fff;
padding: 0;
box-shadow:
0 1px 1px rgba(0,0,0,0.15),
0 10px 0 -5px #eee,
0 10px 1px -4px rgba(0,0,0,0.15),
0 20px 0 -10px #eee,
0 20px 1px -9px rgba(0,0,0,0.15);
}
#quote {
background: #fff;
padding: 0 10px;
margin-top: 75px;
line-height: 1.6em;
}
#character {
color: #f5322d;
margin-right: 25px;
}
@media (max-width: 500px) {
body {
font-size: 14px;
}
#character {
font-size: 1.5em;
}
}
@media (max-width: 768px) {
.post-it {
margin: 0 auto 20px;
max-width: 175px;
z-index: 1000;
}
}
var quotes = [
{
quote: "Even if I didn't love every minute of it, everything I have, I owe to this job. This stupid, wonderful, boring, amazing job.",
character: "Jim Halpert"
},
{
quote: "I took a desk at the back because it was empty. But no matter how you get there or where you end up, human beings have this miraculous gift to make that place home.",
character: "Creed Bratton"
},
{
quote: "I wish there was a way to know you're in the good old days before you've actually left them.",
character: "Andy Bernard"
},
{
quote: "It took me so long to do so many important things. It's just hard to accept that I spent so many years being less happy than I could have been. Jim was 5 feet from my desk and it took me four years to get to him. It'd be great if people saw this documentary and learned from my mistakes. Not that I'm a tragic person. I'm really happy now. But it would just make my heart soar if someone out there saw this and she said to herself 'be strong, trust yourself, love yourself.' Conquer your fears. Just go after what you want and act fast, because life just isn't that long.",
character: "Pam Beesly"
},
{
quote: "Why are you the way that you are? Honestly, every time I try to do something fun or exciting, you make it not that way. I hate so much about the things that you choose to be.",
character: "Michael Scott"
},
{
quote: "There is a master key and a spare key for the office. Dwight has them both. When I asked, 'What if you die, Dwight? How will we get into the office?' He said, 'if I'm dead, you guys have been dead for weeks.'",
character: "Pam Beesly"
},
{
quote: "I DECLARE BANKRUPTCY!",
character: "Michael Scott"
},
{
quote: "I have been Michael Scott's #2 guy for about 5 years. And we make a great team. We're like one of those classic famous teams. He's like Mozart, and I'm like Mozart's friend. No. I'm like Butch Cassidy, and Michael Scott is like Mozart. You try and hurt Mozart; you're going to get a bullet in your head courtesy of Butch Cassidy.",
character: "Dwight Schrute"
},
{
quote: "You don't call retarded people retards. It's bad taste. You call your friends retards when they're acting retarded.",
character: "Michael Scott"
},
{
quote: "Toby is in HR, which technically means he works for corporate, so he's really not a part of our family. Also, he's divorced, so he's really not a part of his family.",
character: "Michael Scott"
},
{
quote: "I think an ordinary paper company like Dunder-Mifflin was a great subject for a documentary. There's a lot of beauty in ordinary things. Isn't that kind of the point?",
character: "Pam Beesly"
},
{
quote: "Let me describe the perfect date: I take her out to a nice dinner; she looks amazing. Some guy tries to hit on her...now he wants to fight, so I grab him, I throw him into the jukebox! Then the other ninja's got a knife, he comes at me, we grapple, I turn his knife on him. Blood on the dance floor! She's scared now. I take her home. I'm holding her in my arms. I reach in for a kiss...I hear something in the leaves, I flip her around, she gets a poison arrow right in her back. She was in on it the whole time...but I knew.",
character: "Dwight Schrute"
},
{
quote: "I don't want somebody sucking up to me because they think I am going to help their career...I want them sucking up to me because they genuinely love me.",
character: "Michael Scott"
},
{
quote: "In the wild, there is no healthcare. Healthcare is 'Oh, I broke my leg!' A lion comes and eats you, you're dead. Well, I'm not dead, I'm the lion, you're dead!",
character: "Dwight Schrute"
},
{
quote: "My perfect Valentine's Day? I'm at home, three cell phones in front of me, fielding desperate calls from people who want to buy one of the fifty restaurant reservations I made over 6 months ago.",
character: "Dwight Schrute"
},
{
quote: "What is my perfect crime? I break into Tiffany's at midnight. Do I go for the vault? No, I go for the chandelier. It's priceless. As I'm taking it down, a woman catches me. She tells me to stop. It's her father's business. She's Tiffany. I say no. We make love all night. In the morning the cops come and I escape in one of their uniforms. I tell her to meet me in Mexico but I go to Canada. I don't trust her. Besides, I like the cold. Thirty years later, I get a postcard. I have a son and he's the chief of police. This is where the story gets interesting: I tell Tiffany to meet me in Paris, by the Trocadero. She's been waiting for me all these years; she's never taken another lover. I don't care, I don't show up. I go to Berlin. That's where I stashed the chandelier.",
character: "Dwight Schrute"
},
{
quote: "Yeah, I have a lot of questions. Number one: how dare you?",
character: "Kelly Kapoor (to Ryan)"
}
];
$(document).ready(function() {
window.onload = function() {
pickQuote();
createButton();
}
var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
// Quote changer
$("#button").on("click", function() {
pickQuote();
createButton();
});
// Animates 'The Office' sign
$(".title-box").on("click", function() {
$(this).addClass("animated hinge").one(animationEnd, function() {
$(this).removeClass("animated hinge");
});
});
// Animates the post-it
$(".title-box").hover(function() {
$(this).addClass("animated swing").one(animationEnd, function() {
$(this).removeClass("animated swing");
});
});
function pickQuote() {
var randomNum = quotes[ Math.floor( Math.random() * quotes.length ) ];
$("#quote").html(randomNum.quote);
$("#character").html("- " + randomNum.character);
}
// Tweet Button - from http://denvycom.com/blog/twitter-button-with-dynamic-custom-data-text-message/
function createButton() {
// Create a New Tweet Element
var tweet;
var msg = document.getElementById('quote').innerHTML;
var author = document.getElementById('character').innerHTML;
if ( msg.length > 77 ) {
var truncated = msg.slice( 0, 77 );
tweet = "\"" + truncated + "..." + "\"" + "\n" + "More quotes from 'The Office' at";
};
if ( msg.length + author.length < 140 ) {
tweet = "\"" + msg + "\"" + " " + author;
};
var link = document.createElement('a');
link.setAttribute('href', 'https://twitter.com/share');
link.setAttribute('class', 'twitter-share-button');
link.setAttribute('style', 'margin-top:5px;');
link.setAttribute('id', 'twitterbutton');
link.setAttribute("data-text", tweet);
link.setAttribute("data-size", "large");
// Put it inside the twtbox div
var tweetdiv = document.getElementById('twtbox');
// Removes previous tweet button if one already exists
while (tweetdiv.firstChild) {
tweetdiv.removeChild(tweetdiv.firstChild)
};
tweetdiv.appendChild(link);
twttr.widgets.load(); //very important
}
});
Also see: Tab Triggers