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 URL's 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 it's URL and the proper URL extention.
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 class="recipe" id="recipe">
<div class="image">
<img src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/3/oatmeal-cookies.jpg" alt="">
</div>
<header>
<h1>The World's Best Oatmeal Cookies</h1>
<a href="#send-form" class="send-badge">
<svg width="24" height="24" viewBox="0 0 24 24">
<path d="M16,18H7V4H16M11.5,22A1.5,1.5 0 0,1 10,20.5A1.5,1.5 0 0,1 11.5,19A1.5,1.5 0 0,1 13,20.5A1.5,1.5 0 0,1 11.5,22M15.5,1H7.5A2.5,2.5 0 0,0 5,3.5V20.5A2.5,2.5 0 0,0 7.5,23H15.5A2.5,2.5 0 0,0 18,20.5V3.5A2.5,2.5 0 0,0 15.5,1Z"></path>
</svg>
SMS
</a>
</header>
<div class="ingredients">
<h3>Ingredients</h3>
<ul>
<li>1 cup (2 sticks) butter</li>
<li>1 cup brown sugar</li>
<li>1 cup white sugar</li>
<li>2 eggs</li>
<li>1 tsp vanilla</li>
<li>1.5 cups white flour</li>
<li>1 tsp baking soda</li>
<li>1/2 tsp salt</li>
<li>3 cups oatmeal</li>
<li>1.5-2 cups chocolate chips</li>
</ul>
</div>
<div class="instructions">
<h3>Steps</h3>
<ol>
<li>Set oven to 350°F</li>
<li>Mix sugars and butter together. You want the butter to be soft. I usually take it out of the fridge a few hours before I start making my cookies. You can microwave the butter but it just doesn’t work out as well.</li>
<li>Add eggs & vanilla, mix</li>
<li>Mix in flour, salt, & baking soda</li>
<li>Mix in the oatmeal</li>
<li>Stir in some semi-sweet chocolate chips I recommend between 1.5 – 2 cups. Mini chocolate chips work well too.</li>
<li>The finished dough won’t look like your typical non-oatmeal dough since there’s less flour in it. That’s fine and expected.</li>
<li>I recommend 3 sheets of 12 cookies each, cooked one sheet at a time.</li>
<li>Depending on your oven and cookie size each batch should take about 10-15 minutes. I average about 12 minutes per cookie sheet.</li>
<li>Here’s the most important part of this recipe and where I usually lose people. You have to take them out before they look totally done. People who haven’t tried my cookies fight me on this, but trust me, you absolutely need to take them out earlier
than you would expect. Judging exactly when is a skill but I’d recommend taking them out when you feel they could use another 3-4 minutes.</li>
</ol>
</div>
<form id="send-form" class="send-form">
<p>Send this recipe to you or a friend!</p>
<label for="sms-number">Text to this number:</label>
<input type="tel" id="sms-number" required placeholder="(555) 555-5555">
<input type="submit" value="Send" id="send-sms-button">
</form>
</div>
@import url("https://fonts.googleapis.com/css?family=Open+Sans:300,400,400i,700");
* {
box-sizing: border-box;
}
html {
font-family: 'Open Sans', sans-serif;
line-height: 1.4;
font-size: calc(0.6vw + 0.6vh + 0.2vmin);
background: linear-gradient(
-25deg,
#5C258D,
#4389A2
);
}
h1 {
font-size: 2rem;
font-weight: 300;
line-height: 1.1;
margin: 0;
}
.recipe {
max-width: 500px;
border-radius: 6px;
overflow: hidden;
margin: 3rem auto;
background: white;
box-shadow: 5px 5px 12px rgba(black, 0.2);
position: relative;
h3 {
margin: 0 0 0.25rem 0;
text-transform: uppercase;
letter-spacing: 0.1rem;
color: #5C258D;
margin: 1rem 0 0.5rem 0;
}
.ingredients ul {
list-style: none;
padding: 0;
margin: 0 0 1rem 0;
li {
background-image: linear-gradient(120deg, #fdfbfb 0%, #ebedee 100%);
display: inline-block;
white-space: nowrap;
padding: 0.2rem 0.3rem;
border-radius: 3px;
margin: 0.2rem 0.1rem;
font-size: 0.85rem;
}
}
.instructions ol {
padding: 0 0 0 1.3rem;
margin: 0;
li {
padding: 0 0 1rem 0;
}
}
img {
display: block;
width: 100%;
height: 200px;
object-fit: cover;
}
header {
padding: 1.5rem 125px 1rem 2rem;
background: linear-gradient(
to bottom,
#ffffb9,
white
);
margin: 0 0 1rem 0;
}
.ingredients,
.instructions {
padding: 0 2rem;
}
.send-badge {
background: #5C258D;
text-align: center;
border-radius: 50%;
height: 80px;
width: 80px;
position: absolute;
right: 20px;
top: 170px;
text-decoration: none;
color: white;
padding: 13px 0 0 0;
font-size: 0.75rem;
svg {
fill: white;
display: block;
margin: 0 auto;
width: 40px;
height: 40px;
}
}
.send-form {
background: #4389A2;
padding: 1rem;
p {
color: #d4eeff;
font-weight: bold;
margin: 0 0 0.75rem 0;
font-size: 1.25rem;
}
label {
color: white;
}
}
}
const cloudless_function_url = 'https://wt-8081b26e05bb4354f7d65ffc34cbbd67-0.run.webtask.io/twilio';
let form = document.querySelector("#send-form");
form.addEventListener("submit", function(e) {
e.preventDefault();
axios.post(cloudless_function_url, {
// message: document.querySelector("#recipe").textContent,
message: `You're gonna need butter and eggs.\n\The rest of the instructions are at: https://codepen.io/chriscoyier/full/xPMpGM/`,
to_number: document.querySelector("#sms-number").value
})
.then(function (response) {
// console.log(response);
})
.catch(function (error) {
// console.log(error);
});
});
// const url = `https://recipe-sender.azurewebsites.net/api/send-recipe?code=uu/fW4xYnk48WquYSBJbp8S2eBiZ1QX3tOxEXEP1Bet7xVeUW3B3pg==`;
Also see: Tab Triggers