Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

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.

+ add another resource

Packages

Add Packages

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.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <div id="Notifications"></div>
<button onclick='Notification("Success", "A successful message has been passed", "good")'>Good</button>
<button onclick='Notification("Warning", "Some warning will be displayed here", "warning")'>Warning</button>
<button onclick='Notification("Error", "An error of some kind has happened", "error")'>Error</button>
              
            
!

CSS

              
                #Notifications {
	position: fixed;
	right: 0;
	top: 0;
} div.Notification {
	display: table;
	min-width: 250px;
	box-shadow: 0 0 3px black;
} div.Notification div.Content {
	padding: 3px;
	margin-left: 70px;
	margin-right: 10px;
} div.Notification h1 {
	padding: 0;
	margin: 0;
} div.Notification.good {
	background-color: #abffcd;
} div.Notification.warning {
	background-color: #ffc693;
} div.Notification.error {
	background-color: #ff9593;
} div.Notification div.ProgressDiv {
	
} div.Notification div.Image {
	width: 60px;
	height: 60px;
	float: left;
	background-size: cover;
} div.Notification div.ProgressDiv div {
	height: 3px;
	width: 0%;
	box-shadow: 0 0 1px black;
} div.Notification.good div.Content {
	color: #009e0a;
} div.Notification.warning div.Content {
	color: #c55c00;
} div.Notification.error div.Content {
	color: #b30300;
} div.Notification.good div.ProgressDiv div {
	background-color: #009e0a;
} div.Notification.warning div.ProgressDiv div {
	background-color: #c55c00;
} div.Notification.error div.ProgressDiv div {
	background-color: #b30300;
} div.Notification.good div.Image {
	background-image: url(https://magicdoor.co.za/images/codepen/good.jpg);
} div.Notification.warning div.Image {
	background-image: url(https://magicdoor.co.za/images/codepen/warning.jpg);
} div.Notification.error div.Image {
	background-image: url(https://magicdoor.co.za/images/codepen/error.jpg);
}
// Basic Buttons - Leave out for notifications

button {
  background-color: #3498db;
  color: white;
  padding: 5px 10px;
  border: 0;
  border-radius: 5px;
}
              
            
!

JS

              
                function Notification(Title, Message, Icon){
	var obj										= {};
	obj.progress								= 0;
	obj.fadeTime								= 1000;
	obj.fadeTicks								= 50;
	obj.fadeInterval							= 0;
	obj.opacity									= 1;
	obj.time									= 2;
	obj.ticks									= 500;
	obj.element									= null;
	obj.progress								= null;
	obj.progressPos								= 0;
	obj.progressIncrement						= 0;
	obj.Show									= function(){
		obj.element								= document.createElement('div');
		obj.element.className					= "Notification "+Icon;
		image									= document.createElement('div');
		image.onclick 							= function(){obj.Clear();};
		image.className							= "Image";
		obj.element.appendChild(image);
		content									= document.createElement('div');
		content.className						= "Content";
		content.innerHTML						= ""+
		"<h1>"+Title+"</h1>"+
		"<label>"+Message+"</label>"+
		"";
		obj.element.appendChild(content);
		var progressDiv							= document.createElement('div');
		progressDiv.className					= 'ProgressDiv';
		obj.progress							= document.createElement('div');
		progressDiv.appendChild(obj.progress);
		obj.element.appendChild(progressDiv);
		obj.progressIncrement					= 100 / obj.ticks;
		document.getElementById('Notifications').appendChild(obj.element);
		obj.StartWait();
	};
	obj.StartWait								= function(){
		if(obj.progressPos >= 100){
			obj.fadeInterval					= 1;
			obj.FadeTick();
			return;
		}
		setTimeout(obj.Tick, obj.time);
	};
	obj.Clear									= function(){
		obj.opacity								= 0;
		obj.progressPos							= 100;
		obj.element.remove();
		obj										= null;
		return;
	};
	obj.FadeTick								= function(){
		obj.opacity								= ((obj.opacity * 100) - obj.fadeInterval) / 100;
		if(obj.opacity <= 0){
			obj.element.remove();
			obj									= null;
			return;
		}
		obj.element.style.opacity				= obj.opacity;
		setTimeout(obj.FadeTick, (obj.fadeTime / obj.fadeTicks));
	};
	obj.Tick									= function(){
		obj.progressPos							+= obj.progressIncrement;
		obj.progress.style.width				= obj.progressPos+"%";
		obj.StartWait();
	};
	obj.Show();
	return obj;
}
              
            
!
999px

Console