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 class='carousel'>
	<div class='card'>
		<span class='service-type'>
			<img class='service-type' alt='Visa' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAAOCAYAAACyyTV4AAAAAXNSR0IArs4c6QAABFtJREFUSA111V9olWUcwPH3PWfnbHNr/2y6mnObbqy1UiNHwgq2SKUg7aKkuivwWqIgiC6Cgi68E4LoTrqoBhlRGUGtC7OIaoY63dwqnWekmy5Pbp1t58/b93s8hwpOP/jsef8853mf5/f83ndhNLqlcWUl3xImc4kgGxaCRBhVx2KFdDa60Tg9mw5fCwpBKaIoauZQcWQxh1asQ4hrSIch4xD0b6G5EztQjbOYxTx98rTFoF8DB+tRBX/ruKv0iWi5GM80JZKFgUIu2RlPFphALh7E44XaIHch6Gn5PAgW/7RjKXbRDiKJyxjFo+hEDJ9gnIe6iC48gJ14Fk7kGL6Ev1uCC3Hyw9iGGuRwFJdwa5LXqhoWG1dWU0HVWnchrBmOV9cMRdl0TSwfn8+Gicej0cWfwgNBnsFu40eH8DBc8dtgEcEL6Idhpk5jO17GI6jHGoxn0A1/V5wkrX0Powcu1JjE71jxpKp1/9RN2p+1OvHOWD6//HF87viW2M3JDVGs0J9KBWe4l8H9uBcJ/IEP0Agn7+Bm/FfU4VXshouZwjTcXrf+RxQfzsK9fwDtKE+Qw2JWj9PemqRXyvFV8uDMSEcwFbYOdsQmDydzC6cGNtU1J6No0Uzsg5MyTmACQ7AejQVcQR/cYktiFUfg9jqGk7QUylns4ngvapGGY5mE8tYXS+3fsw8e6w1Xk4ngm3jb0Eow8FIQNG0bWGruSgaZjIOPwJpxdeWa2sqxgxoX4T2zY10Zju9LczecyAVehglkyWLI+RPogMefwi32xbkLDaU+xQE5/ydiseBbzpaD1gcbCr0LffWZzLp8snaE5W/mulkYx0mYpV6UJ+mWZjEJ+zTAUjiIh3AM7/Pg80zSRfhV2A/LYxFHsQFtcPt9GS8h+59McsFwG+eQT7TvacttHOmLxaJ9nDuYdfUh/NSYMQcqT/IXjrNM4Crt6zAz1qjbbGZegdc7majP3Y1+OI6J8b04BxfqjnmvOHalSV7n5imshYm6uqqWO57mwbs4t8ZS+AJ/oQmu2Oy6Rb/BBwT0/4HmEN7AGOxvmDmz6m+fgpk2XKCTslwcy9iO6uJRpT+s9Hlch5GGnyDjLfgAv2/34TIM++yEddSOeiQQxyCmUYDxIvYg5UkpHGcSc8iVrn1H61ihqa4U33PRN8v/LtaWcQMfYdkTohtui2HB+3YP4En42ZmFtWdG/FYajmmd2cexDevRbW30hHA33J2tuB0L/zdJa2kGbme55k5wfJqtLG4px72wBAwf7LfUCT0H69fvr1u3HiFc5GdYwjBqYRm8iysob7ML2IEWWMuzFSfJRDKk+etSRweL8B6K3y1awww7ObM5Dt92XxLf7k3ws+XkUjDLLvII9sIFmIRpvMnzrtIWw63mwMS40B6cdJCKQd+N3PBhLsRVnscyAzqINem3z+1wDLdWLmgz+jAC743hDC7yW+vtHo7NkvfmMcP18u44rovrhs914ef+BkoYzmc7sKmAAAAAAElFTkSuQmCC' />
		</span>
		<div class='actions'>
			<div class='action-buttons'>
				<div class='edit' onclick='editCardDetails(this)'>Edit</div>
				<div class='delete'>Delete</div>
				<div class='save' onclick='saveCardDetails(this)'>Save</div>
			</div>
		</div>
		<div class='description'>
			<input class='value' placeholder='Card Name' value='PERSONAL' readonly />
		</div>
		<div class='card-number'>
			<input class='value' placeholder='×××× ×××× ×××× 8765' oninput='handleInput(this)' readonly />
		</div>
		<div class='holder-name additional-info'>
			<span class='label'>Card Holder</span>
			<input class='value' value='Mitesh Sawant' readonly />
		</div>
		<div class='expiry-date additional-info'>
			<span class='label'>Expires</span>
			<input class='value' value='09/15' readonly />
		</div>
	</div>
	<div class='card'>
		<span class='service-type'>
			<img class='service-type' alt='Visa' src='data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACkAAAAOCAYAAACyyTV4AAAAAXNSR0IArs4c6QAABFtJREFUSA111V9olWUcwPH3PWfnbHNr/2y6mnObbqy1UiNHwgq2SKUg7aKkuivwWqIgiC6Cgi68E4LoTrqoBhlRGUGtC7OIaoY63dwqnWekmy5Pbp1t58/b93s8hwpOP/jsef8853mf5/f83ndhNLqlcWUl3xImc4kgGxaCRBhVx2KFdDa60Tg9mw5fCwpBKaIoauZQcWQxh1asQ4hrSIch4xD0b6G5EztQjbOYxTx98rTFoF8DB+tRBX/ruKv0iWi5GM80JZKFgUIu2RlPFphALh7E44XaIHch6Gn5PAgW/7RjKXbRDiKJyxjFo+hEDJ9gnIe6iC48gJ14Fk7kGL6Ev1uCC3Hyw9iGGuRwFJdwa5LXqhoWG1dWU0HVWnchrBmOV9cMRdl0TSwfn8+Gicej0cWfwgNBnsFu40eH8DBc8dtgEcEL6Idhpk5jO17GI6jHGoxn0A1/V5wkrX0Powcu1JjE71jxpKp1/9RN2p+1OvHOWD6//HF87viW2M3JDVGs0J9KBWe4l8H9uBcJ/IEP0Agn7+Bm/FfU4VXshouZwjTcXrf+RxQfzsK9fwDtKE+Qw2JWj9PemqRXyvFV8uDMSEcwFbYOdsQmDydzC6cGNtU1J6No0Uzsg5MyTmACQ7AejQVcQR/cYktiFUfg9jqGk7QUylns4ngvapGGY5mE8tYXS+3fsw8e6w1Xk4ngm3jb0Eow8FIQNG0bWGruSgaZjIOPwJpxdeWa2sqxgxoX4T2zY10Zju9LczecyAVehglkyWLI+RPogMefwi32xbkLDaU+xQE5/ydiseBbzpaD1gcbCr0LffWZzLp8snaE5W/mulkYx0mYpV6UJ+mWZjEJ+zTAUjiIh3AM7/Pg80zSRfhV2A/LYxFHsQFtcPt9GS8h+59McsFwG+eQT7TvacttHOmLxaJ9nDuYdfUh/NSYMQcqT/IXjrNM4Crt6zAz1qjbbGZegdc7majP3Y1+OI6J8b04BxfqjnmvOHalSV7n5imshYm6uqqWO57mwbs4t8ZS+AJ/oQmu2Oy6Rb/BBwT0/4HmEN7AGOxvmDmz6m+fgpk2XKCTslwcy9iO6uJRpT+s9Hlch5GGnyDjLfgAv2/34TIM++yEddSOeiQQxyCmUYDxIvYg5UkpHGcSc8iVrn1H61ihqa4U33PRN8v/LtaWcQMfYdkTohtui2HB+3YP4En42ZmFtWdG/FYajmmd2cexDevRbW30hHA33J2tuB0L/zdJa2kGbme55k5wfJqtLG4px72wBAwf7LfUCT0H69fvr1u3HiFc5GdYwjBqYRm8iysob7ML2IEWWMuzFSfJRDKk+etSRweL8B6K3y1awww7ObM5Dt92XxLf7k3ws+XkUjDLLvII9sIFmIRpvMnzrtIWw63mwMS40B6cdJCKQd+N3PBhLsRVnscyAzqINem3z+1wDLdWLmgz+jAC743hDC7yW+vtHo7NkvfmMcP18u44rovrhs914ef+BkoYzmc7sKmAAAAAAElFTkSuQmCC' />
		</span>
		<div class='actions'>
			<div class='action-buttons'>
				<div class='edit' onclick='editCardDetails(this)'>Edit</div>
				<div class='delete'>Delete</div>
				<div class='save' onclick='saveCardDetails(this)'>Save</div>
			</div>
		</div>
		<div class='description'>
			<input class='value' placeholder='Card Name' value='PERSONAL' readonly />
		</div>
		<div class='card-number'>
			<input class='value' placeholder='×××× ×××× ×××× 8765' oninput='handleInput(this)' readonly />
		</div>
		<div class='holder-name additional-info'>
			<span class='label'>Card Holder</span>
			<input class='value' value='Mitesh Sawant' readonly />
		</div>
		<div class='expiry-date additional-info'>
			<span class='label'>Expires</span>
			<input class='value' value='09/15' readonly />
		</div>
	</div>
</div>
              
            
!

CSS

              
                @import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Share+Tech+Mono');

.carousel {
	overflow-x: scroll;
	-webkit-overflow-scrolling: touch;
	white-space: nowrap;
	text-align: center;
	width: 100%;

	.card {
		text-align: left;
		display: inline-block;
		margin: 20px 10px;
		font-family: 'Roboto', sans-serif;
		font-weight: 400;
		-webkit-font-smoothing: antialiased;
		position: relative;
		box-sizing: border-box;
		width: 280px;
		border-radius: 8px;
		padding: 20px;
		background: linear-gradient(150deg, rgba(80,93,107,1) 0%, rgba(80,93,107,1) 50%, rgba(74,88,102,1) 50%, rgba(74,88,102,1) 100%);
		color: white;
		overflow: hidden;

		.service-type {
			line-height: 24px;
			width: 50px;
			height: 16px;

			img {
				width: auto;
				height : auto;
				max-width: 100%;
				max-height: 100%;
			}
		}

		.actions {
			float: right;
			width: 150px;
			overflow: hidden;
			white-space: nowrap;

			.action-buttons {
				float: right;
				font-size: 10px;
				text-align: right;
				text-transform: uppercase;
				letter-spacing: 0.5px;
				transform: translateX(146px);
				transition: transform 0.4s ease;

				.edit, .delete, .save {
					display: inline-block;
					width: 52px;
					border-radius: 3px;
					padding: 4px 5px;
					transition: opacity 0.4s ease;
					vertical-align: middle;
					margin-left: 6px;
					text-align: center;
					user-select: none;
					cursor: pointer;
				}

				.edit, .delete {
					background-color: #4B5968;
					border: 1px solid #89939C;
				}

				.save {
					background-color: #D8DEE1;
					border: 1px solid #87919A;
					color: #4B5968;
					font-weight: 500;
				}

				.save, .delete {
					opacity: 0;
				}
			}

		}

		&.edit-mode {

			.action-buttons {
				transform: translateX(0px);

				.save, .delete {
					opacity: 1;
				}

				.edit {
					opacity: 0;
				}
			}

			.description, .card-number, .additional-info, .holder-name, .expiry-date {

				.value {
					border-bottom: 1px solid #999;
				}
			}
		}

		.description {
			margin: 12px 0;

			.value {
				font-size: 12px;
				font-weight: 700;
				letter-spacing: 1px;
				color: #D3DDE5;
				background: transparent;
				border: none;
				border-bottom: 1px solid transparent;
				outline: none;
				box-sizing: border-box;
				width: 100%;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				text-transform: uppercase;
			}
		}

		.card-number {
			margin: 12px 0;

			.value {
				font-family: 'Share Tech Mono', monospace;
				box-sizing: border-box;
				border: none;
				border-bottom: 1px solid transparent;
				background: transparent;
				outline: none;
				width: 100%;
				font-size: 22px;
				color: white;
				font-weight: 500;
				text-shadow: 1px 1px 2px #333;
			}

			::-webkit-input-placeholder {
				color: white;
			}

			:-moz-placeholder { /* Firefox 18- */
				color: white;  
			}

			::-moz-placeholder {  /* Firefox 19+ */
				color: white;  
			}

			:-ms-input-placeholder {  
				color: white;  
			}
		}

		.additional-info {
			text-transform: uppercase;

			.label {
				font-size: 10px;
				color: #D3DDE5;
				letter-spacing: 1.8px;
			}

			.value {
				display: block;
				font-family: 'Share Tech Mono', monospace;
				font-size: 16px;
				line-height: 24px;
				// letter-spacing: 1px;
				color: white;
				border: none;
				border-bottom: 1px solid transparent;
				background: transparent;
				outline: none;
				margin: 0;
				padding: 0;
				width: 100%;
			}
		}

		.holder-name {
			float: left;

			.value {
				max-width: 160px;
				white-space: nowrap;
				overflow: hidden;
				text-overflow: ellipsis;
				text-transform: uppercase;
				border: none;
				border-bottom: 1px solid transparent;
			}
		}

		.expiry-date {
			float: right;

			.value {
				width: 50px;
				border: none;
				border-bottom: 1px solid transparent;
			}
		}
	}

	// Hack for hiding the number spinner on Webkit browsers
	input[type='number']::-webkit-outer-spin-button,
	input[type='number']::-webkit-inner-spin-button {
		-webkit-appearance: none;
		margin: 0;
	}

	// Hack for hiding the number spinner on FireFox
	input[type='number'] {
		-moz-appearance: textfield;
	}

	// Hack for hiding the validation alert box on Firefox
	input:invalid {
		box-shadow: none;
	}
}
              
            
!

JS

              
                function editCardDetails(editButton) {
	var currentCard = editButton.parentNode.parentNode.parentNode;
	currentCard.classList.add('edit-mode');

	var allInputs = currentCard.getElementsByTagName('input');
	for(var i=0; i<allInputs.length; i++) {
		allInputs[i].readOnly = false;
	}

	allInputs[1].value = '1234 5678 4321 ' + allInputs[1].placeholder.substring(15, 19);
	allInputs[1].placeholder = '';
	allInputs[1].focus();
}

function saveCardDetails(saveButton) {
	var currentCard = saveButton.parentNode.parentNode.parentNode;

	var allInputs = currentCard.getElementsByTagName('input');
	if(allInputs[1].value.replace(/ /g,'').length === 16) {
		// allInputs[0].value = allInputs[0].value.replace(/ /g,'');
		currentCard.classList.remove('edit-mode');

		for(var i=0; i<allInputs.length; i++) {
			allInputs[i].readOnly = true;
		}

		allInputs[1].placeholder = '×××× ×××× ×××× ' + allInputs[1].value.substring(15, 19);
		allInputs[1].value = '';
	}
}

// function handleKeyPress(cardNumberInput) {
//      if((event.charCode < 48 || event.charCode > 57) && (cardNumberInput.value.length > 15)) {
//           event.preventDefault();
//      }
// }

function handleInput(cardNumberInput) {
	// cardNumberInput.value = cardNumberInput.value.replace(/[^\d0-9]/g, '').replace(/(.{4})/g, '$1 ').trim();
	// cardNumberInput.value = cardNumberInput.value.replace(/\s/g, '').replace(/(.{4})/g, '$1 ').trim();

	var position = cardNumberInput.selectionEnd,
	    length = cardNumberInput.value.length;

	cardNumberInput.value = cardNumberInput.value.replace(/[^\d0-9]/g, '').replace(/(\d{4})/g, '$1 ').trim();
	cardNumberInput.selectionEnd = position += ((cardNumberInput.value.charAt(position - 1) === ' ' && cardNumberInput.value.charAt(length - 1) === ' ' && length !== cardNumberInput.value.length) ? 1 : 0);
}
              
            
!
999px

Console