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.
<link href='https://fonts.googleapis.com/css?family=Lato:300,400,700' rel='stylesheet' type='text/css'>
%div.title-container
.title
FlatNotifiy.js v0.1
%a.sub-title{href: 'https://www.twitter.com/screenshake', target: '_blank'}
Super simple notifications by @screenshake
%div.button-container
%a.alert{href: '#', onclick: "flatNotify().alert('Testing Alert Notification',2000)"} Alert
%a.success{href: '#', onclick: "flatNotify().success('Testing Success Notification with a two line message. Sweet right?',1500)"} Success
%a.error{href: '#', onclick: "flatNotify().error('Testing Error Notification with a really long message. I mean come on? Who notifies people like this? This is so wrong on so many levels.',3000)"} Error
@import compass
body
background: #eee
font-family: 'Brandon Grotesque', Avenir, 'Lato', sans-serif
.title-container
margin: 120px auto 0
text-align: center
width: 350px
.title
font-size: 40px
margin-bottom: 15px
.sub-title
text-decoration: none
font-size: 20px
color: #D3D3D3
.button-container
width: 438px
height: 78px
margin: 40px auto 0
a
text-decoration: none
padding: 20px 0
width: 130px
text-align: center
margin: 20px 6px
display: inline-block
color: #FFF
font-size: 20px
border-radius: 5px
transition: all 0.3s
&.success
background: #2ecc71
&.error
background: #e74c3c
&.alert
background: #f1c40f
&:hover
opacity: 0.6
.f-notification
position: fixed
bottom: 20px
right: 20px
text-align: left
width: 300px
min-height: 20px
padding: 20px 40px 20px 18px
border-radius: 5px
color: rgba(255, 255, 255, 0.85)
&:hover
opacity: 0.9
.f-notification-close
background: rgba(77, 77, 79, 0.1)
.f-notification-title
font-weight: 600
color: #4D4D4F
cursor: default
.f-close
position: absolute
right: 15px
top: 20px
height: 20px
width: 20px
line-height: 18px
vertical-align: middle
text-align: center
border-radius: 20px
color: #4D4D4F
cursor: pointer
background: rgba(255, 255, 255, 0.25)
&:hover
background: rgba(77, 77, 79, 0.2)
.f-notification-success
background: #2ecc71
.f-notification-error
background: #e74c3c
.f-notification-alert
background: #f1c40f
.f-show
animation-name: animSlideElastic
animation-duration: 1s
animation-timing-function: linear
.f-hide
animation-name: animSlideElastic
animation-duration: 0.5s
animation-direction: reverse
@keyframes animSlideElastic
0%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1000, 0, 0, 1)
3.333333%
transform: matrix3d(1.96989, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 521.82545, 0, 0, 1)
6.666667%
transform: matrix3d(1.4235, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 218.3238, 0, 0, 1)
10%
transform: matrix3d(1.08167, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 57.59273, 0, 0, 1)
13.333333%
transform: matrix3d(0.99057, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -11.12794, 0, 0, 1)
16.666667%
transform: matrix3d(0.98719, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -30.40503, 0, 0, 1)
20%
transform: matrix3d(0.99541, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -28.10141, 0, 0, 1)
23.333333%
transform: matrix3d(0.99936, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -19.40752, 0, 0, 1)
26.666667%
transform: matrix3d(1.00021, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -11.08575, 0, 0, 1)
30%
transform: matrix3d(1.00016, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -5.23737, 0, 0, 1)
33.333333%
transform: matrix3d(1.00005, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -1.84893, 0, 0, 1)
36.666667%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.22079, 0, 0, 1)
40%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.37284, 0, 0, 1)
43.333333%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.46116, 0, 0, 1)
46.666667%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.35963, 0, 0, 1)
50%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.22487, 0, 0, 1)
53.333333%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.11734, 0, 0, 1)
56.666667%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.04909, 0, 0, 1)
60%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.01295, 0, 0, 1)
63.333333%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.0025, 0, 0, 1)
66.666667%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.00684, 0, 0, 1)
70%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.00632, 0, 0, 1)
73.333333%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.00436, 0, 0, 1)
76.666667%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.00249, 0, 0, 1)
80%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.00118, 0, 0, 1)
83.333333%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.00042, 0, 0, 1)
86.666667%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, -0.00005, 0, 0, 1)
90%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.00008, 0, 0, 1)
93.333333%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.0001, 0, 0, 1)
96.666667%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0.00008, 0, 0, 1)
100%
transform: matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)
/**
*
* flatNotify.js v0.1
* @screenshake
*
* Inspired by :
* https://tympanus.net/codrops/2014/07/23/notification-styles-inspiration/
*
* Animation courtesy :
* bounce.js - http://bouncejs.com/
*
* Class manipulation
* classie.js https://github.com/desandro/classie
*
*/
;( function( window ) {
var proto_methods = {
options: {
wrapper: document.body,
dismissIn: 5000
},
init: function() {
this.ntf = document.createElement('div');
this.ntf.className = 'f-notification';
var strinner = '<div class="f-notification-inner"></div><div class="f-close">x</div></div>';
this.ntf.innerHTML = strinner;
// append to body or the element specified in options.wrapper
this.options.wrapper.insertBefore(this.ntf, this.options.wrapper.lastChild);
// init events
this.initEvents();
},
initEvents: function() {
var self = this;
// dismiss notification
this.ntf.querySelector('.f-close').addEventListener('click', function() {
self.dismiss();
});
},
dismiss: function() {
var self = this;
clearTimeout(this.dismissttl);
classie.remove(self.ntf, 'f-show');
setTimeout(function() {
classie.add(self.ntf, 'f-hide');
}, 25);
setTimeout(function() {
self.options.wrapper.removeChild( self.ntf );
}, 500);
},
setType: function(newType) {
var self = this;
classie.remove(self.ntf, 'f-notification-error');
classie.remove(self.ntf, 'f-notification-alert');
classie.remove(self.ntf, 'f-notification-success');
classie.add(self.ntf, newType);
},
success: function(message, dismissIn) {
var self = this;
/**
* Use supplied dismiss timeout if present, else uses default value.
* If set to 0, doesnt automatically dismiss.
*/
dismissIn = (typeof dismissIn === "undefined") ? this.options['dismissIn'] : dismissIn;
/**
* Set notification type styling
*/
self.setType('f-notification-success');
self.ntf.querySelector('.f-notification-inner').innerHTML = message;
classie.remove(self.ntf, 'f-hide');
classie.add(self.ntf, 'f-show');
if (dismissIn > 0) {
this.dismissttl = setTimeout(function() {
self.dismiss();
}, dismissIn);
}
},
error: function(message, dismissIn) {
var self = this;
/**
* Use supplied dismiss timeout if present, else uses default value.
* If set to 0, doesnt automatically dismiss.
*/
dismissIn = (typeof dismissIn === "undefined") ? this.options['dismissIn'] : dismissIn;
/**
* Set notification type styling
*/
self.setType('f-notification-error');
self.ntf.querySelector('.f-notification-inner').innerHTML = message;
classie.remove(self.ntf, 'f-hide');
classie.add(self.ntf, 'f-show');
if (dismissIn > 0) {
this.dismissttl = setTimeout(function() {
self.dismiss();
}, dismissIn);
}
},
alert: function(message, dismissIn) {
var self = this;
/**
* Use supplied dismiss timeout if present, else uses default value.
* If set to 0, doesnt automatically dismiss.
*/
dismissIn = (typeof dismissIn === "undefined") ? this.options['dismissIn'] : dismissIn;
/**
* Set notification type styling
*/
self.setType('f-notification-alert');
self.ntf.querySelector('.f-notification-inner').innerHTML = message;
classie.remove(self.ntf, 'f-hide');
classie.add(self.ntf, 'f-show');
if (dismissIn > 0) {
this.dismissttl = setTimeout(function() {
self.dismiss();
}, dismissIn);
}
}
}, flatNotify, _flatNotifiy;
_flatNotifiy = function() {
this.init();
};
_flatNotifiy.prototype = proto_methods;
flatNotify = function() {
return new _flatNotifiy();
};
/**
* add to global namespace
*/
window.flatNotify = flatNotify;
} )( window );
Also see: Tab Triggers