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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.
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.
If the stylesheet 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 CSS 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.
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.
<h2>From left to right</h2>
<a href="#" class="btn btn-small btn-l-r">btn small</a>
<a href="#" class="btn btn-medium btn-l-r">btn medium</a>
<a href="#" class="btn btn-large btn-l-r">btn large</a>
<a href="#" class="btn btn-huge btn-l-r">btn huge</a>
<h2>From right to left</h2>
<a href="#" class="btn btn-small btn-r-l">btn small</a>
<a href="#" class="btn btn-medium btn-r-l">btn medium</a>
<a href="#" class="btn btn-large btn-r-l">btn large</a>
<a href="#" class="btn btn-huge btn-r-l">btn huge</a>
<h2>From top to bottom</h2>
<a href="#" class="btn btn-small btn-t-b">btn small</a>
<a href="#" class="btn btn-medium btn-t-b">btn medium</a>
<a href="#" class="btn btn-large btn-t-b">btn large</a>
<a href="#" class="btn btn-huge btn-t-b">btn huge</a>
<h2>From bottom to top</h2>
<a href="#" class="btn btn-small btn-b-t">btn small</a>
<a href="#" class="btn btn-medium btn-b-t">btn medium</a>
<a href="#" class="btn btn-large btn-b-t">btn large</a>
<a href="#" class="btn btn-huge btn-b-t">btn huge</a>
<h2>ِAnimated border</h2>
<a href="#" class="btn btn-small btn-animated-border">btn small</a>
<a href="#" class="btn btn-medium btn-animated-border">btn medium</a>
<a href="#" class="btn btn-large btn-animated-border">btn large</a>
<a href="#" class="btn btn-huge btn-animated-border">btn huge</a>
<h2>ِRotate top left </h2>
<a href="#" class="btn btn-small btn-rotate rotate-t-l">btn small</a>
<a href="#" class="btn btn-medium btn-rotate rotate-t-l">btn medium</a>
<a href="#" class="btn btn-large btn-rotate rotate-t-l">btn large</a>
<a href="#" class="btn btn-huge btn-rotate rotate-t-l">btn huge</a>
<h2>ِRotate top right </h2>
<a href="#" class="btn btn-small btn-rotate rotate-t-r">btn small</a>
<a href="#" class="btn btn-medium btn-rotate rotate-t-r">btn medium</a>
<a href="#" class="btn btn-large btn-rotate rotate-t-r">btn large</a>
<a href="#" class="btn btn-huge btn-rotate rotate-t-r">btn huge</a>
<h2>ِRotate bottom left </h2>
<a href="#" class="btn btn-small btn-rotate rotate-b-l">btn small</a>
<a href="#" class="btn btn-medium btn-rotate rotate-b-l">btn medium</a>
<a href="#" class="btn btn-large btn-rotate rotate-b-l">btn large</a>
<a href="#" class="btn btn-huge btn-rotate rotate-b-l">btn huge</a>
<h2>ِRotate bottom right </h2>
<a href="#" class="btn btn-small btn-rotate rotate-b-r">btn small</a>
<a href="#" class="btn btn-medium btn-rotate rotate-b-r">btn medium</a>
<a href="#" class="btn btn-large btn-rotate rotate-b-r">btn large</a>
<a href="#" class="btn btn-huge btn-rotate rotate-b-r">btn huge</a>
<h2>Shadow from bottom</h2>
<a href="#" class="btn btn-small btn-shadow">btn small</a>
<a href="#" class="btn btn-medium btn-shadow">btn small</a>
<a href="#" class="btn btn-large btn-shadow">btn small</a>
<a href="#" class="btn btn-huge btn-shadow">btn small</a>
/**** Variables ****/
@blue: #2196F3;
@green: #4CAF50;
@pink: #E91E63;
@purple: #9C27B0;
@cyan : #00BCD4;
@teal: #009688;
@red: #F44336;
@white : #fff;
body {
margin: 50px;
text-align: center;
font-family: 'Ubuntu', sans-serif;
}
h2 {
margin: 30px 0;
}
.btn {
position: relative;
background: transparent;
display: inline-block;
text-decoration: none;
border: 1px solid;
border-radius: 4px;
margin-right: 20px;
transition: 0.3s;
&:after {
content: "";
position: absolute;
border-radius: 4px;
transition: 0.3s;
z-index: -1;
background: transparent;
}
&:before {
content: "";
position: absolute;
}
}
/**** from left to right style ****/
.btn-l-r {
color: @blue;
border-color: @blue;
&:hover {
color: @white;
}
&:hover:after {
background: @blue;
width: 100%;
}
&:after {
top: 0;
left: 0;
width: 0%;
height: 100%;
}
}
/**** from right to left style ****/
.btn-r-l {
color: @green;
border-color: @green;
&:hover {
color: @white;
}
&:hover:after {
background: @green;
width: 100%;
}
&:after {
top: 0;
right: 0;
width: 0%;
height: 100%;
}
}
/**** from top to bottom style ****/
.btn-t-b {
color: @pink;
border-color: @pink;
&:hover {
color: @white;
}
&:hover:after {
background: @pink;
height: 100%;
}
&:after {
top: 0;
left: 0;
width: 100%;
height: 0%;
}
}
/**** from bottom to top style ****/
.btn-b-t {
color: @purple;
border-color: @purple;
&:hover {
color: @white;
}
&:hover:after {
background: @purple;
height: 100%;
}
&:after {
bottom: 0;
left: 0;
width: 100%;
height: 0%;
}
}
/**** Animated border ****/
.btn-animated-border {
color: @cyan;
&:hover {
color: darken(@cyan, 10%);
}
&:after {
top: -1px;
left: 0;
width: 0%;
height: 100%;
border-width: 1px 0 1px 0;
border-style: solid;
border-color: darken(@cyan, 10%);
}
&:hover:after {
width: 100%;
}
&:before {
top: 0;
left: -1px;
width: 100%;
height: 0%;
background: transparent;
border-width: 0 1px 0 1px;
border-style: solid;
border-color: darken(@cyan, 10%);
border-radius: 4px;
transition: 0.3s;
}
&:hover:before {
height: 100%;
}
}
/**** General rotate style ****/
.btn-rotate {
color: @teal;
overflow: hidden;
transition: 0.3s;
&:after {
top: 0;
left: 0;
width: 100%;
height: 100%;
background: @teal;
}
&:hover {
color: @white;
border-color: @teal;
}
&:hover:after {
transform: rotate(0deg);
}
}
/**** Rotate top left ****/
.rotate-t-l {
color: @teal;
overflow: hidden;
transition: 0.3s;
&:after {
transform: rotate(-90deg);
transform-origin: top left;
}
}
/**** Rotate top right ****/
.rotate-t-r {
&:after {
transform: rotate(90deg);
transform-origin: top right;
}
}
/**** Rotate bottom left ****/
.rotate-b-l {
&:after {
transform: rotate(90deg);
transform-origin: bottom left;
}
}
/**** Rotate bottom right ****/
.rotate-b-r {
&:after {
transform: rotate(-90deg);
transform-origin: bottom right;
}
}
/**** Button Shadow from bottom ****/
.btn-shadow {
background: @pink;
border: none;
color: @white;
border-radius: 0;
overflow: hidden;
&:after {
top: 100%;
left: 0;
z-index: 10;
width: 100%;
height: 100%;
background: darken(@pink, 7%);
border-radius: 0;
}
&:hover:after {
top: 90%;
}
}
.btn-small {
padding: 2px 7px;
}
.btn-medium {
padding: 7px 13px;
}
.btn-large {
padding: 12px 18px;
}
.btn-huge {
padding: 18px 25px;
}
Also see: Tab Triggers