cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

            
              <div class="no-robots">
	<header>
		<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" viewBox="0 0 50 50" style="enable-background:new 0 0 50 50;" xml:space="preserve">
			<circle class="circle" cx="25" cy="25" r="25"/>
			<polygon class="mountains" points="34.1,25 27.7,13.9 21.3,25 19.2,28.7 16.5,24 13,30 9.5,36.1 14.9,36.1 16.5,36.1 23.5,36.1 27.7,36.1 40.5,36.1"/>
		</svg>
		<h2>Join Our Mailing List</h2>
	</header>
		
	<form class="form"> <!--onsubmit="return addNumbers()"-->
		<div class="row">
			<input class="field" type="text" id="firstName" required />
			<label for="firstName">
				<span>First Name</span>
			</label>
		</div>
		
		<div class="row">
			<input class="field" type="text" id="lastName" required />
			<label for="lastName">
				<span>Last Name</span>
			</label>
		</div>
		
		<div class="row">
			<input class="field" type="email" id="email" required />
			<label for="email">
				<span>Email Address</span>
			</label>
		</div>
		
		<div class="row problem">
			<span class="thin">What is</span>
			<span class="xx" data-value="5">5</span>
			<span>+</span>
			<span class="yy" data-value="6">6</span>
			<span>=</span>
			<input class="answer" id="answer" type="text" value />?
		</div>
		
		<button class="submit">
			Submit
		</button>
	</form>
</div>

<div class="success hide">
	<div class="content">
		<div class="close"></div>
		<h3>Thank you!</h3>
		You have been added to the mailing list. Please check your email and confirm.
	</div>
</div>
            
          
!
            
              @import "bourbon";
@import "neat";

$base-duration: 500ms;

// Colors
$color-1: slategray;
$color-2: lightgray;
$color-3: #2ecc71;

// Breakpoints
$sm: new-breakpoint(min-width 320px);
$med: new-breakpoint(min-width 768px);
$lg: new-breakpoint(min-width 1024px);

*, *:before, *:after {
	box-sizing: border-box;
	outline: none;
}

html {
	font-family: 'Source Sans Pro', sans-serif;
	font-size: 16px;
	font-smooth: auto;
	font-weight: 300;
	line-height: 1.5;
	color: #444;
}

body {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100vh;
	background-color: $color-1;
}

.thin {
	font-weight: 200;
}

.hide {
	display: none !important;
	visibility: hidden !important;
}
.success {
	position: fixed;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	background-color: rgba(black,0.8);
	transition: background-color 250ms linear;
	z-index: 100;
	
	.content {
		position: relative;
		width: 18.75rem;
		padding: 1.875rem;
		background-color: white;
		border-radius: 5px;
		pointer-events: none;
		user-select: none;
		
		.close {
			position: absolute;
			display: flex;
			align-items: center;
			justify-content: center;
			top: 0;
			right: 0;
			width: 40px;
			height: 40px;
			cursor: pointer;
			z-index: 999;
			
			&:before, &:after {
				position: absolute;
				content: '';
				// top: 50%;
				// left: 50%;
				width: 15px;
				height: 2px;
				background-color: black;
				border-radius: 99px;
				transform: translate(-50%,-50%);
			}
			
			&:before {
				transform: rotate(-45deg);
			}
			
			&:after {
				transform: rotate(45deg);
			}
			
			&:hover {
				&:before, &:after {
					background-color: $color-3;
				}
			}
		}
	}
}

.no-robots {
	position: relative;
	display: block;
	margin: 0;
	padding: 2.5rem;
	background-color: white;
	border-radius: 0.3125rem;
	box-shadow: 0 0 2.5rem rgba(black,0.2);
	
	header {
		position: relative;
		display: flex;
		margin: 0 0 30px;
		
		svg {
			position: relative;
			display: inline-block;
			width: 40px;
			height: 40px;
			margin-right: 1rem;
			
			.circle {
				fill: $color-1;
			}
			
			.mountains {
				fill: white;
			}
		}
		
		h2 {
			position: relative;
			display: inline-block;
			margin: 0;
			padding: 0;
			color: $color-1;
		}
	}
	
	form {
		position: relative;
		display: block;
		width: 18.75rem;

		.row {
			position: relative;
			display: block;
			width: 100%;
			height: 30px;
			margin: 0 0 25px;
			padding: 0;
			
			.field {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100% !important;
				margin: 0;
				padding: 5px;
				background-color: transparent;
				border-left: none;
				border-top: none;
				border-right: none;
				border-bottom: 0.0625rem solid $color-2;
				z-index: 1;
				
				&::-webkit-input-placeholder {
					color: $color-2;
					font-weight: 100;
				}
				
				&:focus {
					border-bottom: none;
				}
					
				&:focus, &:valid {	
					~ label {
					
						&:before {
							width: 100%;
							background-color: $color-3;
							z-index: 2;
						}
						
						span {
							top: -10px;
							left: 0;
							font-size: 10px;
							color: $color-3;
						}
					}
				}
			}

			label {
				position: absolute;
				top: 0;
				left: 0;
				width: 100%;
				height: 100%;
				font-size: 12px;
				z-index: 0;
				
				&:before {
					position: absolute;
					content: '';
					bottom: 0;
					left: 0;
					width: 0;
					height: 0.0625rem;
					transition: width 250ms;
					z-index: 2;
				}
				
				span {
					position: absolute;
					top: 5px;
					left: 5px;
					color: #aaa;
					z-index: 5;
					transition: all 250ms;
				}
			}
			
			&.problem {
				position: relative;
				display: flex;
				align-items: center;
				justify-content: center;
				
				> span {
					margin-right: 5px;
				}
				
				> .answer {
					width: 50px;
					padding: 3px;
					margin-right: 3px;
					border-top: none;
					border-right: none;
					border-bottom: 1px solid $color-2;
					border-left: none;
					text-align: center;
					
					&:active, &:focus {
						border-bottom: 1px solid $color-3;
					}
				}
			}
		}
		
		button {
			position: relative;
			display: block;
			margin: 30px auto 0;
			padding: 10px 30px;
			font-size: 16px;
			font-weight: 400;
			color: white;
			background-color: $color-1;
			border: none;
			overflow: hidden;
			z-index: 1;
			
			&:before {
				position: absolute;
				content: '';
				top: 0;
				left: 0;
				width: 0;
				height: 100%;
				background-color: $color-3;
				transition: width 250ms;
				z-index: -1;
			}
			
			&:hover {
				color: white;
				
				&:before {
					width: 100%;
				}
			}
		}
	}
}
            
          
!
            
              const submit = document.querySelector('.submit');
const x = parseInt(document.querySelector('.xx').innerText);
const y = parseInt(document.querySelector('.yy').innerText);
const success = document.querySelector('.success');
const content = document.querySelector('.content');
const close = document.querySelector('.close');
const form = document.querySelector('.form');
const robots = document.querySelector('.no-robots');
const gif = 'https://media.giphy.com/media/111ebonMs90YLu/giphy.gif';
const fail = 'https://media.giphy.com/media/TZFmvyDvr3WaQ/giphy.gif';

function addNumbers(e) {
	let userValue = parseInt(document.querySelector('#answer').value);
	
	if (x + y === userValue) {
		form.classList.add('hide');
		robots.innerHTML = '<img src="' + gif + '" />';
		success.classList.remove('hide');
		e.preventDefault();
	} else {
		form.classList.add('hide');
		robots.innerHTML = '<img src="' + fail + '" />';
	}
}

submit.addEventListener('click',addNumbers);
close.addEventListener('click', () => success.classList.add('hide'));
success.addEventListener('click', () => success.classList.add('hide'));
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console