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.
<h1>Bunch-o-Buttons</h1>
<div class="grid">
<div class="grid-item">
<div class="presentation-block">
<div class="title">Default</div>
<div class="row">
<button class="btn btn-default">Normal</button>
<button class="btn btn-default focus">Hover</button>
<button class="btn btn-default active">Active</button>
<button class="btn btn-default" disabled>Disabled</button>
</div>
<div class="title">Default - Flat</div>
<div class="row">
<button class="btn btn-default btn-flat">Normal</button>
<button class="btn btn-default btn-flat focus">Hover</button>
<button class="btn btn-default btn-flat active">Active</button>
<button class="btn btn-default btn-flat" disabled>Disabled</button>
</div>
</div>
</div>
<div class="grid-item">
<div class="presentation-block">
<div class="title">Primary</div>
<div class="row">
<button class="btn btn-primary">Normal</button>
<button class="btn btn-primary focus">Hover</button>
<button class="btn btn-primary active">Active</button>
<button class="btn btn-primary" disabled>Disabled</button>
</div>
<div class="title">Primary - Flat</div>
<div class="row">
<button class="btn btn-primary btn-flat">Normal</button>
<button class="btn btn-primary btn-flat focus">Hover</button>
<button class="btn btn-primary btn-flat active">Active</button>
<button class="btn btn-primary btn-flat" disabled>Disabled</button>
</div>
</div>
</div>
<div class="grid-item">
<div class="presentation-block">
<div class="title">Success</div>
<div class="row">
<button class="btn btn-success">Normal</button>
<button class="btn btn-success focus">Hover</button>
<button class="btn btn-success active">Active</button>
<button class="btn btn-success" disabled>Disabled</button>
</div>
<div class="title">Success - Flat</div>
<div class="row">
<button class="btn btn-success btn-flat">Normal</button>
<button class="btn btn-success btn-flat focus">Hover</button>
<button class="btn btn-success btn-flat active">Active</button>
<button class="btn btn-success btn-flat" disabled>Disabled</button>
</div>
</div>
</div>
</div>
<div class="grid">
<div class="grid-item">
<div class="presentation-block">
<div class="title">Info</div>
<div class="row">
<button class="btn btn-info">Normal</button>
<button class="btn btn-info focus">Hover</button>
<button class="btn btn-info active">Active</button>
<button class="btn btn-info" disabled>Disabled</button>
</div>
<div class="title">Info - Flat</div>
<div class="row">
<button class="btn btn-info btn-flat">Normal</button>
<button class="btn btn-info btn-flat focus">Hover</button>
<button class="btn btn-info btn-flat active">Active</button>
<button class="btn btn-info btn-flat" disabled>Disabled</button>
</div>
</div>
</div>
<div class="grid-item">
<div class="presentation-block">
<div class="title">Warning</div>
<div class="row">
<button class="btn btn-warning">Normal</button>
<button class="btn btn-warning focus">Hover</button>
<button class="btn btn-warning active">Active</button>
<button class="btn btn-warning" disabled>Disabled</button>
</div>
<div class="title">Warning - Flat</div>
<div class="row">
<button class="btn btn-warning btn-flat">Normal</button>
<button class="btn btn-warning btn-flat focus">Hover</button>
<button class="btn btn-warning btn-flat active">Active</button>
<button class="btn btn-warning btn-flat" disabled>Disabled</button>
</div>
</div>
</div>
<div class="grid-item">
<div class="presentation-block">
<div class="title">Danger</div>
<div class="row">
<button class="btn btn-danger">Normal</button>
<button class="btn btn-danger focus">Hover</button>
<button class="btn btn-danger active">Active</button>
<button class="btn btn-danger" disabled>Disabled</button>
</div>
<div class="title">Danger - Flat</div>
<div class="row">
<button class="btn btn-danger btn-flat">Normal</button>
<button class="btn btn-danger btn-flat focus">Hover</button>
<button class="btn btn-danger btn-flat active">Active</button>
<button class="btn btn-danger btn-flat" disabled>Disabled</button>
</div>
</div>
</div>
</div>
<div class="grid">
<div class="grid-item"> </div>
<div class="grid-item">
<div class="presentation-block">
<div class="title">Size Variants</div>
<div class="row">
<button class="btn btn-default btn-xs">Extra Small</button>
<button class="btn btn-default btn-sm">Small</button>
<button class="btn btn-default">Normal</button>
<button class="btn btn-default btn-lg">Large</button>
</div>
<div class="title">Size Variants - Flat</div>
<div class="row">
<button class="btn btn-default btn-flat btn-xs">Extra Small</button>
<button class="btn btn-default btn-flat btn-sm">Small</button>
<button class="btn btn-default btn-flat">Normal</button>
<button class="btn btn-default btn-flat btn-lg">Large</button>
</div>
</div>
</div>
<div class="grid-item"> </div>
</div>
*,
*:before,
*:after {
box-sizing: border-box;
}
html {
font-size: 62.5%;
}
body {
font-family: 'Roboto', sans-serif;
font-size: 1.6rem;
padding: 20px 80px;
background-color: #eee;
}
h1 {
text-align: center;
font-size: 4rem;
font-weight: 100;
margin-top: 0;
margin-bottom: 20px;
color: #aaa;
}
.grid {
margin-left: -10px;
margin-right: -10px;
&:before,
&:after {
content: " ";
display: table;
}
&:after {
clear: both;
}
}
.grid-item {
width: percentage(1/3);
float: left;
padding-left: 10px;
padding-right: 10px;
}
.presentation-block {
text-align: center;
padding: 10px;
border-radius: 3px;
margin-bottom: 10px;
background-color: #fff;
box-shadow: 0 1px 2px rgba(0,0,0,.075);
.title {
display: block;
text-transform: uppercase;
font-size: 1.4rem;
color: #aaa;
margin-bottom: 10px;
}
.row {
margin-bottom: 10px;
&:last-child {
margin-bottom: 0;
}
}
}
.btn {
display: inline-block;
margin-bottom: 0;
text-align: center;
text-transform: uppercase;
vertical-align: middle;
cursor: pointer;
background-image: none;
whitespace: nowrap;
padding: 6px 12px;
font-size: 1.4rem;
border-radius: 3px;
border: 1px solid transparent;
text-decoration: none;
user-select: none;
&,
&:active,
&.active {
&:focus {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
}
&:hover,
&:focus,
&.focus {
text-decoration: none;
color: #fff;
}
&:active,
&.active {
outline: 0;
background-image: none;
}
&.disabled,
&[disabled],
fieldset[disabled] & {
cursor: not-allowed;
pointer-events: none;
box-shadow: none;
}
&.btn-xs {
padding: 3px 6px;
font-size: 1.2rem;
}
&.btn-sm {
padding: 4px 8px;
font-size: 1.3rem;
}
&.btn-lg {
padding: 8px 16px;
font-size: 1.6rem;
}
}
@mixin btn-variant($border, $from, $to, $gloss, $color, $hover-from, $active-border) {
color: $color;
border-color: $border;
background: linear-gradient(to bottom, $from 0%, $to 100%);
box-shadow: inset 0 1px $gloss, 0 1px 2px rgba(0,0,0,.2);
&:hover,
&:focus,
&.focus {
border-color: $to;
background: linear-gradient(to bottom, $hover-from 0%, $from 100%);
box-shadow: inset 0 1px $color, 0 2px 3px rgba(0,0,0,.2);
}
&:active,
&.active {
border-color: $active-border;
color: $gloss;
background: linear-gradient(to bottom, $to 0%, $border 100%);
box-shadow: inset 0 2px 2px $active-border;
}
&.disabled,
&[disabled],
fieldset[disabled] & {
background: $hover-from;
border-color: $from;
}
}
@mixin btn-flat($active, $hover, $normal, $active-color, $color, $disabled) {
color: $color;
border-color: transparent;
background: $normal;
box-shadow: none;
&:hover,
&:focus,
&.focus {
border-color: transparent;
color: #fff;
background: $hover;
box-shadow: none;
}
&:active,
&.active {
border-color: $active;
color: $active-color;
background: $active;
box-shadow: none;
}
&.disabled,
&[disabled],
fieldset[disabled] & {
background: $disabled;
border-color: $disabled;
}
}
.btn-default {
@include btn-variant(#546e7a, #90a4ae, #78909c, #cfd8dc, #eceff1, #b0bec5, #455a64);
&.btn-flat {
@include btn-flat(#546e7a, #90a4ae, #78909c, #cfd8dc, #eceff1, #b0bec5);
}
}
.btn-primary {
@include btn-variant(#1e88e5, #64b5f6, #42a5f5, #bbdefb, #e3f2fd, #90caf9, #1976d2);
&.btn-flat {
@include btn-flat(#1e88e5, #64b5f6, #42a5f5, #bbdefb, #e3f2fd, #90caf9);
}
}
.btn-success {
@include btn-variant(#43A047, #81C784, #66BB6A, #C8E6C9, #E8F5E9, #A5D6A7, #388E3C);
&.btn-flat {
@include btn-flat(#43A047, #81C784, #66BB6A, #C8E6C9, #E8F5E9, #A5D6A7);
}
}
.btn-info {
@include btn-variant(#00ACC1, #4DD0E1, #26C6DA, #B2EBF2, #E0F7FA, #80DEEA, #0097A7);
&.btn-flat {
@include btn-flat(#00ACC1, #4DD0E1, #26C6DA, #B2EBF2, #E0F7FA, #80DEEA);
}
}
.btn-warning {
@include btn-variant(#FB8C00, #FFB74D, #FFA726, #FFE0B2, #FFF3E0, #FFCC80, #F57C00);
&.btn-flat {
@include btn-flat(#FB8C00, #FFB74D, #FFA726, #FFE0B2, #FFF3E0, #FFCC80);
}
}
.btn-danger {
@include btn-variant(#F4511E, #FF8A65, #FF7043, #FFCCBC, #FBE9E7, #FFAB91, #E64A19);
&.btn-flat {
@include btn-flat(#F4511E, #FF8A65, #FF7043, #FFCCBC, #FBE9E7, #FFAB91);
}
}
Also see: Tab Triggers