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.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<div class="container">
<h1>Checkboxes</h1>
<div class="wrap">
<div class="material-checkbox red">
<input type="checkbox" id="cb1">
<label for="cb1">Danger</label>
</div>
</div>
<div class="wrap">
<div class="material-checkbox green">
<input type="checkbox" id="cb2">
<label for="cb2">Success</label>
</div>
</div>
<div class="wrap">
<div class="material-checkbox blue">
<input type="checkbox" id="cb3">
<label for="cb3">Primary</label>
</div>
</div>
<div class="wrap">
<div class="material-checkbox yellow">
<input type="checkbox" id="cb4">
<label for="cb4">Warning</label>
</div>
</div>
<div class="wrap">
<div class="material-checkbox default">
<input type="checkbox" id="cb5">
<label for="cb5">Default</label>
</div>
</div>
</div>
<span id="credits">
<i class="mdi mdi-xml"></i>
with
<i class="mdi mdi-heart"></i>
by
<a href="https://codepen.io/GuiCavi/" target="_blank">
<i class="mdi mdi-codepen"></i>
</a>
</span>
@import compass
@import url(https://fonts.googleapis.com/css?family=RobotoDraft)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
$red: #db4437
$blue: #4285f4
$yellow: #f4b400
$green: #0f9d58
$default: #e7e6dd
$color-theme: ("red": $red, "green": $green, "blue": $blue, "yellow": $yellow, "default": $default)
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@mixin dim($width, $height:$width)
width: $width
height: $height
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@function unpack($shorthand)
@if length($shorthand) == 1
@return nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1) nth($shorthand, 1)
@else if length($shorthand) == 2
@return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 1) nth($shorthand, 2)
@else if length($shorthand) == 3
@return nth($shorthand, 1) nth($shorthand, 2) nth($shorthand, 3) nth($shorthand, 2)
@else
@return $shorthand
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@mixin pos($position: relative, $coordinates: null null null null)
@if type-of($position) == list
$coordinates: $position
$position: relative
$coordinates: unpack($coordinates)
$offsets: (top: nth($coordinates, 1), right: nth($coordinates, 2), bottom: nth($coordinates, 3), left: nth($coordinates, 4))
position: $position
@each $offset, $value in $offsets
@if is-length($value)
#{$offset}: $value
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
*
+box-sizing(border-box)
&:before, &:after
+box-sizing(border-box)
html
height: 100%
body
min-height: 100%
font-family: 'Roboto', sans-serif
background-color: #123456
display: flex
align-items: center
justify-content: center
svg[hidden]:not(:root)
display: none
////////////////////////////////////////////////////////////////////////
//////////////////// MIXINS
////////////////////////////////////////////////////////////////////////
@mixin material-colors
@each $theme, $color in $color-theme
.material-checkbox.#{$theme}
.circle
background-color: $color
.check
border-color: $color
////////////////////////////////////////////////////////////////////////
//////////////////// MATERIAL-CHECKBOX
////////////////////////////////////////////////////////////////////////
.material-checkbox
position: relative
display: inline-block
vertical-align: middle
input[type='checkbox']
display: none
&:checked ~ label
.box
opacity: 0
+transform(scale(0) rotate(-180deg))
.check
opacity: 1
+transform(scale(1) rotate(45deg))
.circle
+animation(checkboxRipple .3s ease)
label
cursor: pointer
padding-left: 50px
span
display: block
+pos(absolute, null null null 0)
.circle
background-color: rgba(51,51,51,0.67)
top: -30px
left: -30px
z-index: 890
+dim(80px)
+border-radius(50%)
+transform(scale(0))
.box
border: 2px solid #000
z-index: 891
+dim(20px)
+transition(all .3s ease)
.check
top: -7px
left: 6px
border: 2px solid #0f9d58
border-top: none
border-left: none
opacity: 0
z-index: 892
+dim(12px,24px)
+transform(rotate(180deg))
+transition(all .3s ease)
////////////////////////////////////////////////////////////////////////
//////////////////// KEYFRAMES
////////////////////////////////////////////////////////////////////////
+keyframes(checkboxRipple)
0%
opacity: 0
+transform(scale(0))
50%
opacity: 0.67
75%
opacity: 0.1
+transform(scale(1))
100%
opacity: 0
////////////////////////////////////////////////////////////////////////
//////////////////// INVOICING MIXINS
////////////////////////////////////////////////////////////////////////
+material-colors()
////////////////////////////////////////////////////////////////////////
//////////////////// STYLING OTHERS ELEMENTS
////////////////////////////////////////////////////////////////////////
.container
padding: 20px
background-color: #343434
width: 300px
+box-shadow(0px 1px 2px #000)
h1
text-align: center
color: #f0f0f0
font-weight: bold
margin: 0 0 15px
font-size: 26px
letter-spacing: 3px
.material-checkbox
margin: 20px 0
label
color: #f0f0f0
#credits
+text-shadow(1px 1px 2px #222)
position: fixed
bottom: 10px
right: 10px
font-size: 14px
line-height: 1.8
color: #fff
i.mdi
font-size: 28px
vertical-align: middle
margin: 0 10px
&.mdi-heart
color: #FF432F
&.mdi-codepen
color: #2AE052
&.mdi-xml
color: #FFE02F
(function($) {
$.fn.materialCheckbox = function(options) {
var $label = this.find('label[for]');
this.each(function() {
$('<span class="box" />').prependTo($label);
$('<span class="check" />').prependTo($label);
$('<span class="circle" />').prependTo($label);
});
return this;
};
$('.material-checkbox').materialCheckbox();
}(jQuery));
Also see: Tab Triggers