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 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

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

              
                // Animated loading button. Copypaste code as-is
.buttonContainer: .dsButtonAnim: span Animate me
              
            
!

CSS

              
                /* general */
.buttonContainer
	text-align center
	margin 32px 0

/* PARAMETERS */
color = #3dcb5f
colorError = #da3b3b
colorWait = #ffbb00
fontSize = 18px
fontFam = 'Open Sans', 'Century Gothic', 'arial'
sHeight = 3rem
sWidth = 10rem
time1 = .4s
time2 = (time1 / 2)
pulseSize = 1rem
easing1 = cubic-bezier(.9,.1,.1,.9)

/* KEYFRAMES */
@keyframes loadingAnimation
{
	0% {
		box-shadow 0px 0px 0px 0px rgba(colorWait,100%)
	}
	100% {
		box-shadow 0px 0px 0px pulseSize rgba(colorWait,0%)
	}
}

@keyframes showPseudos
{
	0% {
		opacity 0
	}
	100% {
		opacity 1
	}
}


.dsButtonAnim
	text-align center
	display inline-block
	font fontSize fontFam semibold
	text-transform uppercase
	color #fff
	line-height sHeight
	background color
	border-radius 4rem
	cursor pointer
	height sHeight
	transition all time1 easing1
	width sWidth
	
	span
		opacity 1
		transition time2 time1 ease
	
	&.loading
		background colorWait
		width sHeight
		height sHeight
		padding 0rem
		transition all time1 time2 easing1
		animation loadingAnimation (time2*10) (time1*1.2) infinite
		
		span
			opacity 0
			transition time2 ease
			
	&.success
		position relative
		background color
		width sHeight
		height sHeight
		animation none
		transition all time1 easing1
		
		span
			opacity 0
			transition time2 ease
			
		&::before,
		&::after
			content ''
			display inline-block
			position absolute
			height 4px
			background #fff
			transform-origin 0% 50%
			z-index 10
			animation showPseudos time1 time2 easing1 forwards
			opacity 0
			left 48%
			bottom 0.8rem
			
		&::before
			width 14px
			transform rotate(-135deg)
			
		&::after
			margin-left -3px
			width 24px
			transform rotate(-45deg)
	

	

	&.error
		position relative
		background colorError
		width sHeight
		height sHeight
		animation none
		transition all time1 easing1
		
		span
			opacity 0
			transition time2 ease
			
		&::before,
		&::after
			content ''
			display inline-block
			position absolute
			height 4px
			width (sHeight - 8px)
			left 50%
			margin-left ((sHeight - 8) / 2)
			background #fff
			transform-origin 50% 50%
			z-index 10
			animation showPseudos time1 time2 easing1 forwards
			opacity 0
			top 50%
			margin-top -2px
			
		&::before
			transform rotate(-135deg)
			
		&::after
			transform rotate(-45deg)
	
              
            
!

JS

              
                var states = ["error","success"],
	curState = 0;

$(".dsButtonAnim").on('click', function() {
	curState ? curState = 0 : curState = 1;
	
	that = $(this);
	
	if ( that.hasClass("success") )
		{
			that.removeClass("success");
		}
	
	else if ( that.hasClass("error") )
		{
			that.removeClass("error");
		}
	
	else
		{
			that.addClass("loading");

			window.setTimeout(function() {
				that.removeClass("loading").addClass( states[ curState ] );
			}, 4000);
		}
	
});
              
            
!
999px

Console