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="container">
<ul class="collapsible popout">
<li>
<div class="collapsible-header"><i class="material-icons">shopping_cart</i>Order</div>
<div class="collapsible-body" id="order-body">
<div class="container">
<div class="row">
<img class="responsive-img col m6 materialboxed" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-1671/mop.png" alt="Primo Mop" />
<div class="col m5">
<div class="card-panel blue-grey">
<div class="card-content white-text">
<span class="card-title">Primo Mop</span>
<p>Quantity: 20<br>Price: $15.00 USD</p>
</div>
</div>
</div>
</div>
<div class="row">
<div class="card-panel blue-grey">
<div class="card-content white-text center">
<p>Subtotal: 300.00 USD<br>Shipping: $7.50 USD<br>Fees: $2.50 USD</p>
<span class="card-title">Total: $310.00 USD</span>
</div>
</div>
</div>
</div>
</div>
</li>
<li class="active">
<div class="collapsible-header"><i class="material-icons">place</i>Address</div>
<div class="collapsible-body row" id="address-body">
<div class="row">
<div class="col s12">
<div class="card blue-grey">
<div class="card-content white-text">
<span class="card-title">Billing Address</span>
<p>Enter the address associated with your card.</p>
</div>
</div>
</div>
</div>
<div class="container">
<form class="col s12">
<div class="row">
<div class="input-field col s12">
<input placeholder="full name" id="full_name" type="text" class="validate">
<label for="full_name">full name</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input placeholder="email" id="email" type="text" class="validate">
<label for="email">email</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input placeholder="street address" id="street_address" type="text" class="validate">
<label for="street_address">street address</label>
</div>
<div class="input-field col s6">
<input placeholder="suite / apt." id="suite" type="text" class="validate">
<label for="suite">suite / apt.</label>
</div>
</div>
<div class="row">
<div class="input-field col s4">
<input placeholder="city" id="city" type="text" class="validate">
<label for="city">city</label>
</div>
<div class="input-field col s4">
<input placeholder="state" id="state" type="text" class="validate">
<label for="state">state</label>
</div>
<div class="input-field col s4">
<input placeholder="zip" id="zip" type="text" class="validate">
<label for="zip">zip</label>
</div>
</div>
</form>
<form action="#">
<p>
<label>
<input type="checkbox" id="same" onclick="showMe('shipping-input')" />
<span>Different from shipping address?</span>
</label>
</p>
</form>
</div>
<form class="col s12" id="shipping-address">
<div class="row">
<div class="col s12">
<div class="card blue-grey">
<div class="card-content white-text">
<span class="card-title">Shipping Address</span>
<p>Enter the address where your order will be shipped.</p>
</div>
</div>
</div>
</div>
<div class="container">
<div class="row">
<div class="input-field col s6">
<input placeholder="first name" id="first_name" type="text" class="validate">
<label for="first_name">first name</label>
</div>
<div class="input-field col s6">
<input placeholder="last name" id="last_name" type="text" class="validate">
<label for="last_name">last name</label>
</div>
</div>
<div class="row">
<div class="input-field col s12">
<input placeholder="email" id="emailS" type="text" class="validate">
<label for="emailS">email</label>
</div>
</div>
<div class="row">
<div class="input-field col s6">
<input placeholder="street address" id="street_addressS" type="text" class="validate">
<label for="street_addressS">street address</label>
</div>
<div class="input-field col s6">
<input placeholder="suite / apt." id="suiteS" type="text" class="validate">
<label for="suiteS">suite / apt.</label>
</div>
</div>
<div class="row">
<div class="input-field col s4">
<input placeholder="city" id="cityS" type="text" class="validate">
<label for="cityS">city</label>
</div>
<div class="input-field col s4">
<input placeholder="state" id="stateS" type="text" class="validate">
<label for="stateS">state</label>
</div>
<div class="input-field col s4">
<input placeholder="zip" id="zipS" type="text" class="validate">
<label for="zipS">zip</label>
</div>
</div>
</form>
</div>
<button class="btn waves-effect waves-light" type="submit" name="action" onclick="closeAddress(); openSubmit();">Next
<i class="material-icons right">send</i>
</button>
</div>
</li>
<li id="checkout">
<div class="collapsible-header"><i class="material-icons">credit_card</i>Submit</div>
<div class="collapsible-body" id="submit">
<span>
<div class="container">
<div class="row">
<img class="responsive-img" id="accepted-cards" src="https://s3-us-west-2.amazonaws.com/s.cdpn.io/t-1671/card-brands.png" border="0" alt="Accepted Cards" />
</div>
<div class="row">
<div id="iframe-element"></div>
</div>
<div class="row">
<button class="btn-large waves-effect waves-light col m2" type="submit" name="action" id="submit-credit-card-button">Submit
<i class="material-icons right">send</i>
</button>
<div class="col s1"></div>
<a onclick="openPlaid();"id="bank_light_box" class="#2196f3 blue waves-effect waves-light btn-large col m2 offset-m7"><i class="material-icons right">account_balance</i>use ACH</a>
</div>
<div class="row">
<div class="card blue-grey lighten-2">
<div class="card-content white-text">
<p>By clicking submit, you agree to Mop Emporium's <a href="#">refund, cancellation, and return</a> policy.<br>Orders will be shipped in 2-3 business days, at which time tracking information will be provided in a confirmation email.</p>
</div>
</div>
</div>
</div>
</span>
</div>
</li>
</ul>
<div class="row">
<div id="token"></div>
<div id="tokenBank"></div>
<div class="row">
<div id="complete-screen" class="row">
<div class="col s12 m12">
<div class="card blue-grey darken-1">
<div class="card-content white-text">
<span class="card-title">Your order is complete!</span>
<p>We're working on getting your order ready to ship. Once it does, you can log in and track it here.<br><br><br><br><br></p>
</div>
<div class="card-action">
<a href="#">Track your order</a>
<a href="#">Help</a>
</div>
</div>
</div>
</div>
</div>
</div>
#shipping-address {
display: none;
}
#complete-screen {
display: none;
}
//insert your app ID
var appId = 601904;
document.addEventListener("DOMContentLoaded", function () {
// initialize materialize collapsible
var collapsibleElement = document.querySelector(".collapsible");
var collapsibleInstance = M.Collapsible.init(collapsibleElement);
// initialize materialize material box
var materialBox = document.querySelectorAll(".materialboxed");
var instances = M.Materialbox.init(materialBox);
});
// show shipping address if different
function showMe() {
var box = document.getElementById("same");
var vis = box.checked ? "block" : "none";
document.getElementById("shipping-address").style.display = vis;
}
// close address section on "next" click
function closeAddress() {
var elems = document.querySelector(".collapsible");
var instances = M.Collapsible.init(elems);
instances.close(1);
}
// open submit section on "next" click
function openSubmit() {
var elems = document.querySelector(".collapsible");
var instances = M.Collapsible.init(elems);
instances.open(2);
}
function openPlaid() {
WePay.set_endpoint("stage");
document.getElementById('bank_popup');
response = WePay.bank_account.create({
'client_id': appId,
'email': document.getElementById("email").value,
"options": {
"avoidMicrodeposits": true
}
},
function(data) {
console.log(data);
//close checkout section
var elems = document.querySelector('.collapsible');
var instances = M.Collapsible.init(elems);
instances.close(2);
//display the response for testing -- remove in production
var node = document.createElement('div');
node.innerHTML = ("bank_account_id: " + data["bank_account_id"]);
document.getElementById('token').appendChild(node);
//show complete message
document.getElementById('complete-screen').style.display = "block";
}
);
};
// credit card iframe styling
var custom_style = {
"styles": {
"base": {
"color": "grey",
"border": "1px solid grey",
"border-top": "none",
"border-right": "none",
"border-left": "none",
"font-weight": "200",
"font-family": "Arial",
"padding": "0px",
"margin-bottom": "5px",
":focus": {
"border": "2px solid #4db6ac",
"border-top": "none",
"border-right": "none",
"border-left": "none"
},
"::placeholder": {
"text-transform": "lowercase",
"color": "#D3D3D3",
"font-size": "17px"
}
},
"invalid": {
"color": "#CD5C5C",
"border-color": "#CD5C5C"
},
"valid": {
"color": "#4db6ac",
"border-color": "#4db6ac"
},
"labels": {
"base": {
"color": "gray",
"font-family": "Arial",
"font-size": "13px",
"font-weight": "1",
"text-transform": "lowercase",
"padding": "0px",
"padding-left": "0px"
}
},
"errors": {
"invalid": {
"color": "#CD5C5C"
}
}
}
};
var options = {
custom_style: custom_style
};
//credit card iframe configs
WePay.set_endpoint("stage");
var iframe_container_id = "iframe-element";
var creditCard = WePay.createCreditCardIframe("iframe-element", options);
if (creditCard.error_code) {
console.log("error", creditCard);
}
document
.getElementById("submit-credit-card-button")
.addEventListener("click", function (event) {
creditCard.tokenize(
{
"client_id": appId,
"user_name": document.getElementById("zip").value,
"email": document.getElementById("email").value,
"address": {
"postal_code": document.getElementById("zip").value
}
},
function (response) {
if (response.error) {
// error will have error message which explains why submitToken is not be able to generate token
console.log(response);
} else {
// response will has credit card token if all the user information are valid
console.log(response);
}
// display the response on the page for testing purposes; do not launch with this section
var node = document.createElement('div');
node.innerHTML = JSON.stringify(response);
document.getElementById('token').appendChild(node);
}
)
});
Also see: Tab Triggers