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

              
                .contain
	.wrap
		input id="q" type="text" placeholder="Search..."/
		br/
		p.small Ex. search "cat videos!y" to find cat videos on YouTube.
		/footer.dim.small The search functionality doesn't work in CodePen's iframes :(
		
              
            
!

CSS

              
                @import 'compass/css3';
@import '//cdn.tjg.io/fonts/circular-pro/style.css';

$font-sans: 'Circular Pro', sans-serif;
$font-mono: monospace;
$input-color: #71095b;
$time: 0.25s;

@mixin maybe-nested($sel) {
  @at-root #{if(not &, $sel, selector-append(&, $sel))} {@content}
}
@mixin placeholder {
  @include maybe-nested('::-webkit-input-placeholder') {@content}
  @include maybe-nested(':-moz-placeholder') {@content}
	@include maybe-nested('::-moz-placeholder') {@content}
  @include maybe-nested(':-ms-input-placeholder') {@content}
}

*, *::before, *::after {
	@include box-sizing(border-box);
	@include transition(all $time);
	margin: 0;
	padding: 0;
	border: 0;
	vertical-align: baseline;
}
*:focus {
	outline: none;
}
@include placeholder {
	@include transition(all $time);
}
body {
	font-family: $font-sans;
	font-size: 1.2rem;
	line-height: 1.2;
	padding: 1rem;
	height: 100%;
	background: $input-color;
}
.contain {
	width: 90%;
	max-width: 42rem;
	margin: 6rem auto 0;
	margin: 30vh auto 0;
}
@media (max-width: 550px){
	body {
		font-size: 2rem;
	}
}
.wrap {
	position: relative;
	text-align: center;
}

.z-1 {@include box-shadow(0 2px 5px 0 rgba(#000, 0.16), 0 2px 10px 0 rgba(#000, 0.12))}
.z-2 {@include box-shadow(0 8px 17px 0 rgba(#000, 0.2), 0 6px 20px 0 rgba(#000, 0.19))}
.z-3 {@include box-shadow(0 12px 15px 0 rgba(#000, 0.24), 0 17px 50px 0 rgba(#000, 0.19))}

@include placeholder {
	color: rgba(#fff, .2);
	font-family: $font-sans;
}
input {
	position: absolute;
	font-family: $font-sans;
	left: 0;
	top: 1px;
	//@extend .z-1;
	width: 100%;
	@include placeholder {
		margin: 0 auto;
	}
	font-size: inherit;
	line-height: 1.2;
	padding: .5rem 1rem;
	background: rgba(#fff, .1);
	color: rgba(#fff, 1);
	border-radius: .25em;
	border: 1px solid rgba(#fff, 0);
	/*&:hover, &:focus {
		@include placeholder {
			color: rgba(#fff, .5);
			font-weight: 300;
		}
		//border: 1px solid rgba(#fff, .9);
	}
	&:hover {
		@extend .z-1;
		background: rgba(#fff, .2);
		top: 1px
	}*/
	&:focus {
		@extend .z-1;
		background: rgba(#fff, .2);
		top: 0;
	}
}

footer {
	position: fixed;
	width: 100%;
	bottom: 0;
	left: 0;
	padding-bottom: 2rem;
}

.small {
	font-size: 1rem;
}
p {
	color: rgba(#fff, .3);
	margin-top: 3rem;
}
input ~ p {
	opacity: 0;
}
input:focus ~ p {
	opacity: .5;
}

@media (max-width: 20rem) {
	input {
		font-size: 1rem;
	}
	p {
		margin-top: 1.5rem;
	}
}
              
            
!

JS

              
                // @travis-g
// Uses LozenJS, not jQuery! (https://github.com/travis-g/LozenJS)

var $q, s = "";

var search = [
	["", "https://www.google.com/#q="],
	["!g", "https://www.google.com/#q="],
	["!i", "https://www.google.com/search?tbm=isch&q="],
  ["!y", "https://www.youtube.com/results?search_query="]
]

// init()
$.asap($, function() {
  for (var i = 0; i < search.length; i++)
    if (search[i][0] == "") s = search[i][1];
  if (s == "") {
    alert("Error: Missing default search engine!");
  }
	$q = $('#q');
	$q.value = "";
	//$q.focus(); // uncomment this to autofocus the searchbar on page load
});

var handle = function(e, q) {
	var key = e.keycode || e.which;
	if (key == 13) {
		$.c.log("Enter pressed");
		var url;
		if (q.lastIndexOf("!") != -1) {
			var x = q.lastIndexOf("!"), found = false;
			for (var i=0; i < search.length; i++) {
				if (search[i][0] == q.substr(x)) {
					found = true;
					//$.c.log('Searching!');
					url = search[i][1] + q.substr(0, x).replace(/&/g, "%26");
				}
			}
			if (!found) {
				//$.c.log('Unknown engine, using default')
				url = s + q.substr(0, x).replace(/&/g, "%26");
			}
		} else {
			//$.c.log("No specified engine");
			url = s + q.replace(/&/g, "%26");
		}
		$.c.log(url);
		$.w.location = url;
	}
}

$.on($q, 'keypress', function(e) {
	handle(e, $q.value)
})

              
            
!
999px

Console