123

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              %link{:rel => "stylesheet", :href => "//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css", :type => "text/css"}

.container
	%h1 Go on, click me!
	.search-box-container
		%button.submit
			%i.fa.fa-search	
		%input.search-box
	%h3.response
            
          
!
            
              $bgcolor = #FFECB3
$border = 3px solid #F44336

translateVert()
	-moz-transform: translateY(arguments);
	-webkit-transform: translateY(arguments);
	-o-transform: translateY(arguments);
	-ms-transform: translateY(arguments);
	transform: translateY(arguments);
	
rotate_()
	-moz-transform: rotate(arguments);
	-webkit-transform: rotate(arguments);
	-o-transform: rotate(arguments);
	-ms-transform: rotate(arguments);
	transform: rotate(arguments);

html, body
	width 100%
	height 100%
	margin 0
	padding 0
	
body
	background-color $bgcolor
	overflow hidden
	
*
	box-sizing border-box
	
.container
	display block
	position absolute
	text-align center
	width 100%
	top 50%
	padding 50px 0
	translateVert(-50%)
	background-color rgba(211, 45, 45, 0.2)
	
.container:before
	content ''
	display block
	position absolute
	width 150%
	height 100%
	top 0
	left -25%
	rotate_ -3deg
	z-index -1
	background-color rgba(244, 67, 54, 0.15)
	
h1
	font-family "Lato"
	font-size 1.3em
	color white
	letter-spacing 1px
	margin-bottom 50px
	
h3
	display block
	height 19px
	margin-top 30px
	font-family "Lato"
	font-size 1em
	color white
	opacity 0
	
.search-box-container
	display inline-block
	box-sizing content-box
	height 50px
	width 50px
	padding 0
	background-color white
	border $border
	border-radius ((@height + 6) / 2)
	overflow hidden
	
.search-box-container *
	display inline-block
	margin 0
	height 100%
	padding 5px
	border 0
	outline none
	
.search-box
	width calc(100% - 50px)
	padding 0 20px
	float left
	font-family "Lato"
	font-size 1em
	color #212121
	background-color white
	
.submit
	float right
	width 50px
	left 0
	top 0
	font-size 1.2em
	text-align center
	cursor pointer
	background-color white
	
.fa
	display inline !important
	line-height 100%
	pointer-event none
	color #D32F2F
            
          
!
            
              $.fn.toggleState = function(b) {
	$(this).stop().animate({
		width: b ? "300px" : "50px"
	}, 600, "easeOutElastic" );
}

$(document).ready(function() {
	var container = $(".container");
	var boxContainer = $(".search-box-container");
	var submit = $(".submit");
	var searchBox = $(".search-box");
	var response = $(".response");
	var isOpen = false;
	submit.on("mousedown", function(e) {
		e.preventDefault();
		boxContainer.toggleState(!isOpen);
		isOpen = !isOpen;
		if(!isOpen) {
			handleRequest();
		} else {
			searchBox.focus();
		}	
	});
	searchBox.keypress(function(e) {
		if(e.which === 13) {
			boxContainer.toggleState(false);
			isOpen = false;
			handleRequest();
		}
	});
	searchBox.blur(function() {
		boxContainer.toggleState(false);
		isOpen = false;
	});
	function handleRequest() {
		// You could do an ajax request here...
		var value = searchBox.val();
		searchBox.val('');
		if(value.length > 0) {
			response.text(('Searching for "' + value + '" . . .'));
			response.animate({
				opacity: 1
			}, 300).delay(2000).animate({
				opacity: 0
			}, 300);
		}
	}
});
            
          
!
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.

Console