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

              
                <!DOCTYPE html>
<html>
<head>

	<title>Survey Page</title>

	<link rel="stylesheet" type="text/css" href="survey_style.css">

	<link href="https://fonts.googleapis.com/css?family=Raleway:400,500" rel="stylesheet">

	<script type="text/javascript" src="survey.js"></script>

</head>


<body>
	<header>
			<h1 id="title">Gaming Survey</h1>
			<p id="description">Gaming trends and consumer behaviour survey</p>			
	</header>


	<main>

		<h2>Please fill out the form below:</h2>
		<form id="survey-form">
			<fieldset>
				<label for="name" id="name-label">Name</label>
				<input id="name" type="text" name="name" placeholder="eg. John Doe" required>

				<label for="email" id="email-label">Email</label>
				<input id="email" type="email" name="email" placeholder="eg. john@yahwee.com" required>

				<label for="number" id="number-label">Age</label>
				<input id="number" type="number" name="age" min="0" max="100" placeholder="eg. 32" required>
				<!-- <input id="age" type="number" name="age" pattern=".{1,3}" title="1 to 3 digits"> -->			
			</fieldset>


			<fieldset>
				<label for="dropdown">Which platform do you prefer to play games on?</label>
					<select id="dropdown" name="platform" required>
						<option value="">--Please select an option--</option>
						<option value="PC">PC</option>
						<option value="Xbox">Xbox</option>
						<option value="Playstation">Playstation</option>
						<option value="Nintendo">Nintendo</option>
						<option value="Other">Other</option>         <!-- If 'other' bring up another tab to specify -->
					</select>
				<div id="input-other">
				</div>
				<p><em>(Select "other" for pop-up input field)</em></p>

			</fieldset>

			<p></p>

			<fieldset>
				<legend>How much do you spend on games per year?</legend>
				<div>
					<input id="0-50" type="radio" name="spendings" value="0-50"> 
					<label class="boxes" for="0-50">0-50</label>
				</div>
				<div>
					<input id="50-100" type="radio" name="spendings" value="50-100"> 
					<label class="boxes" for="50-100">50 - 100</label>
				</div>
				<div>
					<input id="100-200" type="radio" name="spendings" value="100-200"> 
					<label class="boxes" for="100-200">100 - 200</label>
				</div>
				<div>
					<input id="200more" type="radio" name="spendings" value="200-plus"> 
					<label class="boxes" for="200more">200 or more</label>
				</div>
			</fieldset>


			<fieldset>
				<legend>Which genres of games do you play? (Select all that apply)</legend>
				<div>				
					<input class="check" type="checkbox" name="genre" value="arpg" id="arpg">
					<label class="boxes" for="arpg">Action RPG</label>
				</div>
				<div>
					<input class="check" type="checkbox" name="genre" value="sports" id="sports">
					<label class="boxes" for="sports">Sports</label>
				</div>
				<div>
					<input class="check" type="checkbox" name="genre" value="rts" id="rts">
					<label class="boxes" for="rts">Real Time Strategy</label>
				</div>
				<div>
					<input class="check" type="checkbox" name="genre" value="mmorpg" id="mmorpg">
					<label class="boxes" for="mmorpg">MMORPG</label>
				</div>
				<div>
					<input class="check" type="checkbox" name="genre" value="puzzle" id="puzzle">
					<label class="boxes" for="puzzle">Puzzle</label>
				</div>				
			</fieldset>

			<fieldset>
				<legend>What features do you expect from a modern gaming console?</legend>
				<textarea name="features" rows="5" placeholder="remember: fix indentation problem here">
				</textarea>
			</fieldset>
			<input type="submit" id="submit" value="Send">			
		</form>		
	</main>

	<footer>		
	</footer>

</body>
</html>
              
            
!

CSS

              
                * {
	margin: 0;
	padding: 0;
	font-family: 'Raleway', sans-serif;
	box-sizing: border-box;
}

::-webkit-scrollbar {
    width: 0px;  
}

html {
	background: #efe8ff;
	margin: 10px auto;
}

body {
	max-width: 1000px;
	margin: 0 auto;
	background: #efe8ff;

}

header {
	background-image: url("https://images.unsplash.com/photo-1560253023-3ec5d502959f?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEyMDd9&auto=format&fit=crop&w=1950&q=80");	
	width: 100%;
	height: 300px;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	display: flex;
	flex-direction: column;
	justify-content: center;
	align-items: center;
	border-radius: 10px;
	margin-bottom: 10px;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
}

h1 {
	font-size: 5rem;
	letter-spacing: 0.5px;
	text-transform: uppercase;
	mix-blend-mode: lighten;
	background: rgba(255,255,255,0.7);
	border-radius: 10px;
	text-shadow: 3px 3px 5px grey;
	padding: 10px;
	text-align: center;
}

header p {
	color: rgba(225,225,225,0.7);
	font-size: 2rem;
	text-align: center;
}

/*//////////////////////////////// MAIN ///////////////////////////*/

main {
	display: flex;
	flex-direction: column;
	align-items: center;
	border-radius: 10px;
	background: white;
  box-shadow: 2px 2px 8px rgba(0,0,0,0.5);
}

h2 {
	margin: 30px auto 30px auto;
	color: #433661;
}

fieldset {
	display: flex;
	border-style: none;
	margin: 30px;
	align-items: center;
	justify-content: center;
}

input {
	margin: 10px auto;
	width: 100%;
	max-width: 500px;
	border-radius: 5px;
	border: 2px solid #433661;
	height: 30px;
	padding-left: 5px;
	box-sizing: border-box;
}

input:focus, textarea:focus {
	outline: none;

}

label {
	font-weight: 500;
	font-size: 1.2rem;
	color: #433661;
	width: 100%;
	margin-top: 20px;
}

legend {
	font-weight: 500;
	font-size: 1.2rem;
	color: #433661;
	margin: 10px auto;
	width: 100%;
	max-width: 500px;
	border-radius: 5px;
	padding: 10px 0;
}

select {
	margin: 10px auto;
	width: 100%;
	background: #efe8ff;
	outline: none;
	border: 2px solid #433661;
	border-radius: 5px;
	padding: 4px;
}

em {
	color: orange;
}

input[type=checkbox], [type=radio] {
	width: 20px;
	margin: 0;
}

fieldset div {
	display: flex;
	margin: 10px 0;
}

.boxes {
	margin: 3px 0 0 10px;
	font-weight: 400;
}

textarea {
	margin: 0 auto;
	width: 100%;
	max-width: 500px;
	max-height: 100px;
	border: 2px solid #433661;
	border-radius: 5px;
	resize: none;
}

input[type=submit] {
	max-width: 100px;
	border-radius: 25px;
	margin: 0 auto 30px auto;
	display: block;
	background: #efe8ff;
	color: #433661;
	font-weight: 500;
	padding: 0;
}

/*//////////////////////////////// MEDIA QUERIES //////////////////////////////*/


@media (max-width: 768px) {

 	html {
		margin: 0;
	}

	header {
		border-radius: 0;
		margin: 0;
	}

	main {
		border-radius: 0;
	}

}

@media (max-width: 480px) {

	header {
		height: 100px;
	}

	h1 {
		font-size: 2rem;
	}

	header p {
		display: none;
	}

	h2 {
		font-size: 1rem;
		margin: 5px auto;
	}

	fieldset {
		display: flex;
		border-style: none;
		margin: 5px;
		align-items: center;
		justify-content: center;
	}

	label {
		margin: 5px auto;
		font-size: 0.8rem;
	}

	#dropdown {
		margin-bottom: 0;
	}

	#input-other {

		margin: 2px auto;
	}

	em {
		font-size: 0.8rem;
	}

	legend {
		font-size: 0.8rem;
		font-weight: 500;
		margin-bottom: 0;
	}
}




              
            
!

JS

              
                // Insert an input-element if user selects "other" from dropdown:


window.onload=function(){

	var html = '<label for="other">Other</label><input id="other" type="text" name="platform" placeholder="If other, please specify.">';

	var getDiv = document.getElementById('input-other');

	var listenEl = document.getElementById('dropdown');


	listenEl.addEventListener('change', function(){

		if (this.value === 'Other' && getDiv.children.length === 0) {

			getDiv.insertAdjacentHTML('afterbegin', html);
		} 
		else if (this.value !== 'Other' && getDiv.children.length > 0) {

			while (getDiv.hasChildNodes()) {
				getDiv.removeChild(getDiv.firstChild);
			}
		}
	})
};

              
            
!
999px

Console