Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

Save Automatically?

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

              
                <a id="alert" href="#">Alert</a>
<br><br>
<a id="prompt" href="#">Prompt</a>
<br><br>
<a id="confirm" href="#">Confirm</a>

<div id="scroller" style="height: 9999px;"></div>
              
            
!

CSS

              
                /* 
	
The MIT License (MIT)

Copyright (c) 2017 Etienne Martin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/

#dialog-holder,#dialog-overlay{position:absolute;top:0;left:0;right:0;transform:translateZ(0)}#dialog-holder,#dialog-holder #dialog-center td .dialog-alert label input{font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}#dialog-overlay{bottom:0;z-index:966;color:#fff;text-align:center;font-size:18px;text-shadow:none;background:rgba(51,51,51,.6);opacity:0;transition:opacity .5s}#dialog-overlay.dialog-closing{transition:opacity .25s}#dialog-overlay.dialog-visible{opacity:1}#dialog-holder{height:100%;z-index:977;cursor:default}#dialog-holder.dialog-fixed{position:fixed;overflow:auto}#dialog-holder #dialog-center{width:100%;height:100%;z-index:999;border-spacing:0;padding:0;margin:0}#dialog-holder #dialog-center td{text-align:center;vertical-align:middle;padding:5%;margin:0;width:90%;perspective:1000px}#dialog-holder #dialog-center td .dialog-alert{position:relative;margin:0 auto;padding:10px 30px;background:#fff;z-index:999;max-width:400px;word-break:break-word;display:none;border-radius:4px;box-shadow:rgba(0,0,0,.1) 0 2px 3px,rgba(0,0,0,.2) 0 5px 15px;opacity:0;transition:transform .5s,opacity .45s;font-size:14px;color:#666}@keyframes shake{20%,60%{transform:translateX(-12px) rotateY(-8deg)}40%,80%{transform:translateX(12px) rotateY(8deg)}}#dialog-holder #dialog-center td .dialog-alert[data-dialog-animation=scale]{-ms-transform:scale(.8);transform:scale(.8)}#dialog-holder #dialog-center td .dialog-alert[data-dialog-animation=slide]{-ms-transform:translateY(-50%);transform:translateY(-50%)}#dialog-holder #dialog-center td .dialog-alert.dialog-closing{transition:transform .25s,opacity .2s}#dialog-holder #dialog-center td .dialog-alert.dialog-visible{-ms-transform:scale(1);transform:scale(1);opacity:1}#dialog-holder #dialog-center td .dialog-alert.dialog-shaking{animation:shake .5s linear}#dialog-holder #dialog-center td .dialog-alert .dialog-border{position:absolute;top:-1px;left:-1px;right:-1px;bottom:-1px;border:1px solid #000;z-index:-1;border-radius:5px;opacity:.2}#dialog-holder #dialog-center td .dialog-alert .dialog-title{padding:20px 5px 0;line-height:25px;font-size:24px;display:block;color:#555;font-weight:400}#dialog-holder #dialog-center td .dialog-alert .dialog-title:empty{padding-top:0}#dialog-holder #dialog-center td .dialog-alert .dialog-message{padding:20px 5px 0;line-height:1.444;display:block;max-width:370px;margin:0 auto}#dialog-holder #dialog-center td .dialog-alert .dialog-message a{color:#007eff}#dialog-holder #dialog-center td .dialog-alert .dialog-message:empty{padding-top:0}#dialog-holder #dialog-center td .dialog-alert label{display:block;margin:20px auto 0;max-width:300px}#dialog-holder #dialog-center td .dialog-alert label input{box-sizing:border-box;padding:15px 20px;border:2px solid #007eff;border-radius:100px;outline:0;width:100%;font-size:14px;color:#555}#dialog-holder #dialog-center td .dialog-alert .dialog-cancel,#dialog-holder #dialog-center td .dialog-alert .dialog-confirm{display:block;margin:20px auto 10px;padding:15px 30px;background:#eee;cursor:pointer;border-radius:100px;font-weight:700;max-width:240px;transition:background .25s;box-shadow:inset 0 -1px 0 rgba(0,0,0,.1);-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}#dialog-holder #dialog-center td .dialog-alert .dialog-cancel:hover,#dialog-holder #dialog-center td .dialog-alert .dialog-confirm:hover{background:#e1e1e1}#dialog-holder #dialog-center td .dialog-alert .dialog-cancel:active,#dialog-holder #dialog-center td .dialog-alert .dialog-confirm:active{box-shadow:inset 0 1px 0 rgba(0,0,0,.1)}#dialog-holder #dialog-center td .dialog-alert .dialog-cancel.dialog-confirm,#dialog-holder #dialog-center td .dialog-alert .dialog-confirm.dialog-confirm{background:#007eff;color:#fff;margin-bottom:20px}#dialog-holder #dialog-center td .dialog-alert .dialog-cancel.dialog-confirm:hover,#dialog-holder #dialog-center td .dialog-alert .dialog-confirm.dialog-confirm:hover{background:#0071e6}#dialog-holder #dialog-center td .dialog-alert .dialog-cancel.dialog-cancel+.dialog-confirm,#dialog-holder #dialog-center td .dialog-alert .dialog-confirm.dialog-cancel+.dialog-confirm{margin-top:10px}#dialog-holder #dialog-center td .dialog-alert .dialog-close{position:absolute;top:15px;right:15px;margin-bottom:-10px;cursor:pointer;line-height:10px;padding:5px;font-size:24px;opacity:.5;transition:opacity .25s;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;-webkit-transform:translateZ(0)}#dialog-holder #dialog-center td .dialog-alert .dialog-close:hover{opacity:1}#dialog-holder #dialog-center td .dialog-alert .dialog-close:before{content:"";position:absolute;top:-15px;left:-15px;right:-15px;bottom:-15px}#dialog-holder #dialog-center td .dialog-alert .dialog-clearFloat{clear:both;width:100%;height:1px;display:block}
              
            
!

JS

              
                /* 
	
The MIT License (MIT)

Copyright (c) 2017 Etienne Martin

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

*/

"use strict";!function(a){window.dialog={defaultParams:{title:"",message:"",button:"Ok",cancel:"Cancel",required:!1,position:"fixed",animation:"scale",input:{type:"text"},validate:function(a){},callback:function(a){}},transitionEnd:"transitionend webkitTransitionEnd oTransitionEnd otransitionend MSTransitionEnd",alert:function(b){dialog.appendDialogHolder();var b=a.extend(!0,{},dialog.defaultParams,b),c=dialog.generateRandomId(),d='<div class="dialog-alert" id="'+c+'">';d+='<div class="dialog-border"></div>',d+='<div class="dialog-title">'+b.title+"</div>",d+='<div class="dialog-message">'+b.message+"</div>",d+='<div class="dialog-close">&times;</div>',d+='<div class="dialog-confirm">'+b.button+"</div>",d+='<div class="dialog-clearFloat"></div>',d+="</div>",dialog.holder.find("td").append(d);var e=a("#"+c),f=e.find(".dialog-confirm"),g=e.find(".dialog-close");b.required===!0&&g.remove(),e.attr("data-dialog-position",b.position),e.attr("data-dialog-animation",b.animation),dialog.injectDialog(),f.one("click.dialog",function(){b.callback(!0)}),g.one("click.dialog",function(){b.callback(null)})},prompt:function(b){dialog.appendDialogHolder();var b=a.extend(!0,{},dialog.defaultParams,b),c=dialog.generateRandomId(),d="";for(var e in b.input)d+=" "+e+'="'+b.input[e]+'" ';var f='<div class="dialog-alert" id="'+c+'">';f+='<div class="dialog-border"></div>',f+='<div class="dialog-title">'+b.title+"</div>",f+='<div class="dialog-message">'+b.message+"</div>",f+="<label><input "+d+" /></label>",f+='<div class="dialog-close">&times;</div>',f+='<div class="dialog-confirm">'+b.button+"</div>",f+='<div class="dialog-clearFloat"></div>',f+="</div>",dialog.holder.find("td").append(f);var g=a("#"+c),h=g.find(".dialog-confirm"),i=g.find(".dialog-close"),j=g.find("input");b.required===!0&&i.remove(),g.attr("data-dialog-position",b.position),g.attr("data-dialog-animation",b.animation),dialog.injectDialog(),h.bind("click.dialog",function(){var a=j.val(),c=b.validate(a)!==!1;return b.required===!0&&""===a&&(c=!1),c?void b.callback(a):(g.one("webkitAnimationEnd oanimationend msAnimationEnd animationend",function(a){g.removeClass("dialog-shaking")}).addClass("dialog-shaking"),!1)}),i.one("click.dialog",function(){b.callback(null)})},confirm:function(b){dialog.appendDialogHolder();var b=a.extend(!0,{},dialog.defaultParams,b),c=dialog.generateRandomId(),d='<div class="dialog-alert" id="'+c+'">';d+='<div class="dialog-border"></div>',d+='<div class="dialog-title">'+b.title+"</div>",d+='<div class="dialog-message">'+b.message+"</div>",d+='<div class="dialog-close">&times;</div>',d+='<div class="dialog-cancel">'+b.cancel+"</div>",d+='<div class="dialog-confirm">'+b.button+"</div>",d+='<div class="dialog-clearFloat"></div>',d+="</div>",dialog.holder.find("td").append(d);var e=a("#"+c),f=e.find(".dialog-confirm"),g=e.find(".dialog-cancel"),h=e.find(".dialog-close");b.required===!0&&h.remove(),e.attr("data-dialog-position",b.position),e.attr("data-dialog-animation",b.animation),dialog.injectDialog(),f.one("click.dialog",function(){b.callback(!0)}),g.one("click.dialog",function(){b.callback(!1)}),h.one("click.dialog",function(){b.callback(null)})},generateRandomId:function(){return Math.floor(1e6*Math.random())+1+(new Date).getTime()},showDialog:function(){a(":focus").blur();var b=a(".dialog-alert:first");"absolute"===b.attr("data-dialog-position")?(dialog.holder.removeClass("dialog-fixed"),dialog.holder.css("top",a(window).scrollTop())):(dialog.holder.addClass("dialog-fixed"),dialog.holder.css("top","")),a(window).trigger("resize.dialog"),a(".dialog-alert").hide(),b.show(),setTimeout(function(){b.bind(dialog.transitionEnd,function(c){a(c.target).is(this)&&(b.unbind(dialog.transitionEnd),dialog.focusElement(b.find("input")[0],!0))}).addClass("dialog-visible")},1),a("html").addClass("dialogIsVisible")},injectDialog:function(){0===a(".dialog-alert:visible").length?dialog.showDialog():a(".dialog-alert:last").hide(),dialog.overlay.addClass("dialog-visible")},focusElement:function(b,c){b&&(a(b).one("blur.dialog",function(){dialog.focusElement(b,!1)}),b.focus(),c&&(void 0!==b.selectionStart&&b.setSelectionRange(b.value.length,b.value.length),b.scrollLeft=b.scrollWidth))},appendDialogHolder:function(){dialog.holder||(a("body").append('<div id="dialog-overlay"></div><div id="dialog-holder"><table id="dialog-center"><tr><td></td></tr></table></div>'),dialog.overlay=a("#dialog-overlay"),dialog.holder=a("#dialog-holder"),dialog.bindDialogGlobalEvents(),a("html").addClass("dialogHolderIsVisible"))},removeDialogHolder:function(){dialog.unbindDialogGlobalEvents(),dialog.overlay.remove(),dialog.holder.remove(),dialog.overlay=void 0,dialog.holder=void 0,a("html").removeClass("dialogHolderIsVisible")},close:function(){var b=a(".dialog-alert:not(.dialog-closing):first");b.addClass("dialog-closing").bind(dialog.transitionEnd,function(c){a(c.target).is(this)&&(b.unbind(dialog.transitionEnd),b.remove(),a("html").removeClass("dialogIsVisible"),0===a(".dialog-alert").length?dialog.overlay.addClass("dialog-closing").bind(dialog.transitionEnd,function(b){a(b.target).is(this)&&(dialog.overlay.unbind(dialog.transitionEnd),dialog.removeDialogHolder())}).removeClass("dialog-visible"):dialog.showDialog())}).removeClass("dialog-visible")},bindDialogGlobalEvents:function(){dialog.holder.add(dialog.overlay).bind("click.dialog",function(b){a(b.target).closest(".dialog-alert").is(".dialog-alert")||a(".dialog-close:visible").trigger("click")}),a(document).on("click.dialog",".dialog-confirm, .dialog-cancel, .dialog-close",function(a){return dialog.close(),!1}),a(document).bind("keyup.dialog",function(b){27==b.keyCode&&a(".dialog-alert").is(":visible")&&a(".dialog-close:visible").trigger("click")}),a(document).bind("keydown.dialog",function(b){var c=a(".dialog-alert:visible");if(0!==c.length)return 13==b.keyCode?(c.find(".dialog-confirm").trigger("click"),!1):void 0}),a(window).bind("resize.dialog",function(){dialog.overlay.height("100%"),dialog.overlay.height(a(document).height())})},unbindDialogGlobalEvents:function(){dialog.overlay.off(".dialog"),dialog.holder.off(".dialog"),a(document).off(".dialog"),a(window).off(".dialog")}}}(jQuery);

$("#alert").click(function(){
		dialog.alert({
			title: "Alert example",
			message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consectetur lacus at gravida luctus. Duis vitae magna tellus. In risus lorem, mollis vel nisi vitae, suscipit aliquet tortor.",
			button: "Ok",
			animation: "fade",
			callback: function(value){
				console.log(value);
			}
		});
		return false;
	});
	
	$("#prompt").click(function(){
		dialog.prompt({
			title: "Prompt example",
			message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consectetur lacus at gravida luctus. Duis vitae magna tellus. In risus lorem, mollis vel nisi vitae, suscipit aliquet tortor.",
			button: "Send",
			required: true,
			position: "absolute",
			animation: "slide",
			input: {
				type: "password",
				placeholder: "This is a placeholder..."
			},
			validate: function(value){
				if( $.trim(value) === "" ){
					return false;
				}
			},
			callback: function(value){
				console.log(value);
			}
		});
		return false;
	});
	
	$("#confirm").click(function(){
		dialog.confirm({
			title: "Confirm example",
			message: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce consectetur lacus at gravida luctus. Duis vitae magna tellus. In risus lorem, mollis vel nisi vitae, suscipit aliquet tortor.",
			cancel: "Cancel",
			button: "Accept",
			required: true,
			callback: function(value){
				console.log(value);
			}
		});
		return false;
	});
              
            
!
999px

Console