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.
.container
h2 Bootstrap 4 - Icon Buttons
hr
h5.text-center Basic Icon Button
.inline-btns
button.btn.btn-danger.btn-icon
i.material-icons warning
span Delete Account
button.btn.btn-outline-danger.btn-icon
i.material-icons warning
span Delete Account
.inline-btns
button.btn.btn-primary.btn-icon
span Send Message
i.material-icons send
button.btn.btn-outline-primary.btn-icon
span Send Message
i.material-icons send
.inline-btns
button.btn.btn-info.btn-icon
i.material-icons cached
span Refresh
button.btn.btn-outline-info.btn-icon
i.material-icons cached
span Refresh
.inline-btns
button.btn.btn-dark.btn-icon
i.material-icons dashboard
button.btn.btn-outline-dark.btn-icon
i.material-icons dashboard
hr
h5.text-center Shaded Icon Button
.inline-btns
button.btn.btn-danger.left.danger.shaded.btn-icon
i.material-icons warning
span Delete Account
button.btn.btn-outline-danger.left.danger.outline.shaded.btn-icon
i.material-icons warning
span Delete Account
.inline-btns
button.btn.btn-primary.right.primary.shaded.btn-icon
span Send Message
i.material-icons send
button.btn.btn-outline-primary.right.primary.outline.shaded.btn-icon
span Send Message
i.material-icons send
.inline-btns
button.btn.btn-info.left.info.shaded.btn-icon
i.material-icons cached
span Refresh
button.btn.btn-outline-info.left.info.outline.shaded.btn-icon
i.material-icons cached
span Refresh
hr
p Bootstrap 4 is a fantastic overhaul of the Bootstrap framework. While they chose not to include their own set of icons in this iteration, there are many other offerings available for use. One of these offerings is Material Design Icons - an icon set offered conveniently through Google Web Fonts.
p This is a collection of examples of label buttons built for Bootstrap 4 using the Material Design Icon font.
/**
* Relevant CSS
* ------------
* This works best if you are building your own bootstrap from src and can use their functions to build classes for each shaded button color variant with specific background-colors for each type.
* You then also wouldn't need to include the extraneous .outline/.primary/.info etc. classes since you could use the bootstrap build functions instead to include your overrides.
* This codepen, however, is done without doing that in case you would rather use the pre-compiled version of bootstrap
*/
//bootstrap variables
$primary: #007bff;
$dark: #343a40;
$info: #17a2b8;
$danger: #dc3545;
$input-btn-padding-x: .75rem !default;
//configurable variables
$btn-icon-shaded-bg-color: rgba(darken($dark, 20%), 0.3);
$btn-icon-shaded-bg-primary-color: rgba(darken($primary, 15%), 0.5);
$btn-icon-shaded-bg-danger-color: rgba(darken($danger, 15%), 0.5);
$btn-icon-shaded-bg-info-color: rgba(darken($info, 15%), 0.5);
$btn-icon-shaded-outline-bg-primary-color: rgba(lighten($primary, 15%), 0.3);
$btn-icon-shaded-outline-bg-danger-color: rgba(lighten($danger, 15%), 0.3);
$btn-icon-shaded-outline-bg-info-color: rgba(lighten($info, 15%), 0.3);
$btn-icon-shaded-spacing: 1.2rem;
$btn-icon-shaded-padding: 0.4rem;
$btn-left-icon-margin: $input-btn-padding-x;
$btn-right-icon-margin: $input-btn-padding-x;
$btn-icon-padding: $input-btn-padding-x*2 + $btn-icon-shaded-spacing;
button.btn {
//basic buttons without shaded icons
&.btn-icon {
display: flex;
//when icon is given before text, render on left
//if i is an only child we shouldn't add a margin - it's an icon button
& > i:first-child:not(:only-child) {
margin-right: $btn-left-icon-margin;
}
//when icon is given after text, render on right
& > span + i {
margin-left: $btn-right-icon-margin;
}
}
//shaded buttons
&.shaded.btn-icon {
display: flex;
position: relative;
&.shaded {
& > i {
//center icons
display: flex;
align-items: center;
//place on top of button
position: absolute;
z-index: 100;
top: 0;
border-radius: 0;
padding: 0 $btn-icon-shaded-padding;
height: 100%;
&::before {
background-color: $btn-icon-shaded-bg-color;
content: '';
width: 100%;
height: 100%;
position: absolute;
top: 0;
left: 0;
//let icon appear over the overlay
z-index: -10;
}
}
}
&.left.shaded {
padding-left: $btn-icon-padding;
& > i {
left: 0;
border-top-left-radius: inherit;
border-bottom-left-radius: inherit;
margin-right: $btn-left-icon-margin;
}
}
&.right.shaded {
padding-right: $btn-icon-padding;
& > i {
right: 0;
border-top-right-radius: inherit;
border-bottom-right-radius: inherit;
margin-left: $btn-right-icon-margin;
}
}
&.primary > i::before {
background-color: $btn-icon-shaded-bg-primary-color;
}
&.danger > i::before {
background-color: $btn-icon-shaded-bg-danger-color;
}
&.info > i::before {
background-color: $btn-icon-shaded-bg-info-color;
}
&.outline.primary > i::before {
background-color: $btn-icon-shaded-outline-bg-primary-color;
}
&.outline.danger > i::before {
background-color: $btn-icon-shaded-outline-bg-danger-color;
}
&.outline.info > i::before {
background-color: $btn-icon-shaded-outline-bg-info-color;
}
}
}
/**
* Styles for CodePen
*/
body {
padding: 2em;
background-color: #505c73;
.container {
background-color: #FEFEFE;
height: 100%;
border-radius: 1em;
padding: 2em;
button {
margin: 0.25em;
}
.inline-btns {
display: flex;
justify-content: space-around;
flex-direction: row;
}
}
}
Also see: Tab Triggers