css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <div class="scene">
	<div class="sky">
		<h1 class="ui">Drag the roof up!</h1>
		<p class="ui">press space to hide UI</p>
		<div class="flare flare1"></div>
		<div class="flare flare2"></div>
		<div class="flare flare3"></div>
	</div>
	<div class="side-l ui">
		<div class="price">$</div>
	</div>
	
	<div class="building-wrap">
		<div class="building">
			<div class="floor">
				<div class="window"></div>
				<div class="window open"></div>
				<div class="window"></div>
				<div class="window"></div>
			</div>
		</div>
	</div>
	
	<div class="side-r">
		<div class="bush bush1"></div>
		<div class="tree tree1"></div>
		<div class="tree tree2"></div>
	</div>
	<div class="street">
		<div class="car"></div>
	</div>
</div>
            
          
!
            
              $wall: #fe994c;
$roof: #a5754a;
$bot: #655246;
$street: #483f38;
$sky: #8ab6dd;
$gold: #fed330;
$tree: #a25741;
$treetop: #60c454;
$sun: #fff7b3;

$cubic: cubic-bezier(0.785, 0.135, 0.15, 0.86);

@mixin pseudo($display: block, $pos: absolute, $content: '') {
	content: $content;
	display: $display;
	position: $pos;
}

::selection {
	background: darken(#ff9a44, 5);
	color: lighten(#ff9a44, 20);
}

html, body {
	width: 100%;
	height: 100%;
}

body {
	overflow: hidden;
}

.scene {
	width: 100%;
	height: 100%;
	position: relative;
	display: grid;
	grid: 
		"sky sky sky" 1fr
		"side-l building side-r" auto
		"street street street" 60px
		/ 1fr auto 1fr;
	background-image: linear-gradient(to top, #bdc2e8 0%, #bdc2e8 1%, #e6dee9 100%);
	background-image: linear-gradient(-20deg, #fc6076 0%, #ff9a44 100%);
	
	&:before {
		@include pseudo;
		width: 100%;
		height: 100%;
		background: #ff9a44;
		mix-blend-mode: screen;
		opacity: .3;
		z-index: 1;
		animation: overlay 10s $cubic infinite;
	}
}

.sky {
	grid-area: sky;
	position: relative;
	padding: 0 10px;
	
	h1 {
		font-size: 1.6rem;
		color: lighten(#000, 10);
		text-align: right;
		margin: 10px 0;
	}
	
	p {
		text-align: right;
		margin: 0;
	}
}
.side-l {
	grid-area: side-l;
	position: relative;
	
	&:before {
		@include pseudo;
		width: calc(100% - 130px);
		height: 2px;
		background: darken($sky, 10);
		right: 100px;
		top: 0;
		z-index: 99;
		opacity: .5;
	}
	
	.price {
		padding: 10px 20px;
		background: transparentize(darken($sky, 10),.3);
		border-radius: 10px 0 10px 10px;
		margin: 0 20px;
		display: inline-block;
		color: $gold;
		font-size: 1.4rem;
		letter-spacing: 2px;
		position: relative;
		z-index: 100;
	}
}
.side-r {
	grid-area: side-r;
	position: relative;
}
.building-wrap{
	grid-area: building;
	position: relative;
	
	&:before {
		@include pseudo;
		width: calc(100% + 20px);
		height: 10px;
		background: $roof;
		top: -10px;
		left: -10px;
		box-shadow: inset 0 1px 0 0 rgba(0,0,0,.1);
	}
	
	&:after {
		@include pseudo;
		width: calc(100% + 10px);
		height: 5px;
		background: darken($roof, 5);
		top: 0;
		left: -5px;
		box-shadow: inset 0 1px 0 0 rgba(100,100,100,.5);
	}
	
	.building {
		display: grid;
		grid-template-rows: 40px;
		align-content: end;
		background: $wall;
		padding-bottom: 40px;
		min-height: 60px;
		box-shadow:
			inset 0 10px 0 0 rgba(0,0,0,.2),
			inset 5px 0 0 0 #fff,
			inset -5px 0 0 0 #fff,
			inset 6px 0 0 0 rgba(0,0,0,.2),
			inset -6px 0 0 0 rgba(0,0,0,.2),
			inset 0 -5px 6px 0 rgba(0,0,0,.2),
			inset 0 -20px 0 0 $bot,
			inset 0 -21px 0 0 rgba(255,255,255,.3);
		padding-left: 10px;
		padding-right: 10px;
		
		&:before {
			@include pseudo;
			width: calc(100% + 40px);
			height: 5px;
			top: -15px;
			left: -20px;
			background: lighten($roof, 5);
			box-shadow: inset 0 1px 0 0 rgba(255,255,255,.3);
		}
		
		&:after {
			@include pseudo;
			width: 20px;
			height: 10px;
			background: darken($bot, 10);
			left: -20px;
			bottom: 0;
			box-shadow:
				-20px 0 0 0 darken($bot, 10),
				0 -10px 0 0 darken($bot, 10),
				0 -60px 0 0 $bot;
		}
	}
}
.street {
	grid-area: street;
	background: $street;
	box-shadow: inset 0 20px 0 0 darken($street, 5),
		inset 0 21px 0 0 $street,
		inset 0 30px 0 0 darken($street, 10),
		inset 0 31px 0 0 darken($street, 20);
	border-top: 1px solid darken($street, 20);
	position: relative;
}

.floor {
	display: grid;
	grid-template-columns: auto;
	grid-template-rows: 40px;
	grid-auto-flow: column;
	padding-top: 20px;
	height: 60px;
	box-sizing: border-box;
	position: relative;
	
	&:before {
		@include pseudo;
		width: calc(100% + 30px);
		background: #fff;
		height: 4px;
		left: -15px;
		bottom: -5px;
		box-shadow: 0 1px 0 0 darken(#fff, 15);
	}
	&:after {
		@include pseudo;
		width: calc(100% + 10px);
		background: #fff;
		height: 4px;
		left: -5px;
		bottom: -10px;
		box-shadow: 0 2px 0 0 rgba(0,0,0,.2);
	}
	
	&:first-child {
		padding-top: 0;
		
		&:before {
			bottom: 15px;
		}
		
		&:after {
			bottom: 10px;
		}
	}
	
	.window {
		width: 40px;
		margin: 0 10px;
		background: darken($bot, 20);
		position: relative;
		border: 2px solid #fff;
		
		&.open {
			&:before {
				height: 50%;
			}
		}
		
		&:before {
			@include pseudo;
			width: 100%;
			height: 100%;
			left: 0;
			top: 0;
			background: rgba(255,255,255,.4);
			transition: height .4s $cubic;
			box-shadow: inset 0 2px 0 0 rgba(0,0,0,.2);
		}
		
		&:after {
			@include pseudo;
			width: 100%;
			height: 2px;
			top: 50%;
			background: #fff;
			box-shadow: 0 2px 0 0 rgba(0,0,0,.2);
		}
	}
}

// Resize handles
.ui-resizable-handle {
	width: 10px;
	height: 100%;
	position: absolute;
}

.ui-resizable-n {
	width: 100%;
	height: 20px;
	top: -15px;
	left: 0;
	background: transparent;
	cursor: s-resize;
}

.tree {
	position: absolute;
	bottom: 0;
	background: $tree;
	
	>.particle {
		opacity:0;
		position: absolute;
		background-color: transparentize($treetop, .5);
		animation: leaves 3s ease-in infinite;
		border-radius: 0 50%;
	}
}

.tree1 {
	width: 10px;
	height: 100px;
	left: 10vw;
	box-shadow: inset 0 40px 0 0 rgba(0,0,0,.2);
	
	&:before {
		@include pseudo;
		width: 80px;
		height: 80px;
		background: $treetop;
		border-radius: 50%;
		left: -70px;
		top: -50px;
		box-shadow:
			30px -40px 0 0 $treetop,
			60px 5px 0 0 $treetop,
			50px -30px 0 0 $treetop,
			15px 10px 0 0 $treetop;
	}
	&:after {
		@include pseudo;
		width: 30px;
		height: 4px;
		background: $tree;
		right: -28px;
		top: 30px;
		transform: rotate(-20deg);
		box-shadow: inset 5px 0 0 0 rgba(0,0,0,.2);
	}
}

.tree2 {
	width: 8px;
	height: 80px;
	right: 15vw;
	box-shadow: inset 0 30px 0 0 rgba(0,0,0,.2);
	
	&:before {
		@include pseudo;
		width: 50px;
		height: 50px;
		background: $treetop;
		border-radius: 50%;
		left: -50px;
		top: -40px;
		box-shadow:
			35px -30px 0 0 $treetop,
			25px 15px 0 0 $treetop,
			50px -5px 0 0 $treetop,
			10px -25px 0 0 $treetop;
	}
	&:after {
		@include pseudo;
		width: 15px;
		height: 4px;
		background: $tree;
		left: -14px;
		top: 40px;
		transform: rotate(20deg);
	}
}

@keyframes leaves {
   0% {
     opacity: 0;
		 bottom: 100%;
		 transform: rotate(0);
   }
   80% {
      opacity: 1;
   }
   100% {
		 opacity: 0;
		 bottom: 0;
		 transform: rotate(360deg);
   }
}

.bush {
	position: absolute;
	bottom: 0;
	background: $treetop;
}

.bush1 {
	left: 0;
	width: 30px;
	height: 30px;
	border-radius: 35% 50% 0 0;
	
	&:before {
		@include pseudo;
		width: 20px;
		height: 20px;
		border-radius: 50% 50% 20% 0;
		right: -16px;
		bottom: 0;
		background: $treetop;
	}
}

.flare {
	position: absolute;
	background: transparentize($sun, .7);
	clip-path: polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}

.flare1 {
	width: 200px;
	height: 200px;
	top: -80px;
	left: -50px;
	transform: rotate(20deg);
	animation: flare 40s ease infinite;
}

.flare2 {
	width: 150px;
	height: 150px;
	top: 30px;
	left: 80px;
	transform: rotate(120deg);
	animation: flare 40s ease infinite;
	animation-direction: reverse;
}

.flare3 {
	width: 100px;
	height: 100px;
	top: 110px;
	left: 190px;
	transform: rotate(20deg);
	animation: flare 30s ease infinite;
	animation-delay: .5s;
}

@keyframes flare {
	0% {
		transform: rotate(20deg);
	}
	33% {
		transform: rotate(-80deg);
	}
	66% {
		transform: rotate(100deg);
	}
	100% {
		transform: rotate(20deg);
	}
}

@keyframes overlay {
	0% {
		opacity: .3;
	}
	33% {
		opacity: .5;
	}
	50% {
		opacity: .4;
	}
	70% {
		opacity: .2;
	}
	100% {
		opacity: .3;
	}
}
            
          
!
            
              $('.building').resizable({
	handles: "n",
	minHeight: 60,
	grid: 60
});

$('.building').resize(function() {
	stop();
});

function stop() {
	var floor = '<div class="floor"><div class="window"></div><div class="window"></div><div class="window"></div><div class="window"></div></div>'
	
	var buildingHeight = $('.building').outerHeight();
	buildingHeight = buildingHeight - 40; // padding bottom
	var floorHeight = $('.floor').outerHeight();
	
	// check how many floors fit the building
	var floors = Math.floor(buildingHeight / floorHeight);
	
	var currentFloors = $('.building .floor').length;
	
	// get the difference
	var diff = floors - currentFloors;
	
	if (diff < 0) {
		diff = diff * -1;
		
		for(var i = 0; i < diff; i++) {
			// remove top floor
			$('.building').find('.floor:first').remove();
		}
		
	} else {
		// add floor on top
		for(var i = 0; i < diff; i++) {
			$('.building').prepend(floor);
		}
	}
	
	// show price tag
	var price = Math.round(floors / 2);
	var pricetag = [];
	
	for (var i = 0; i < price; i++) {
		pricetag.push('$');
	}
	
	$('.price').html(pricetag);
	
	// randomly open windows
	var classes = ["", "open", ""];

	$(".window").each(function(){
		$(this).removeClass(classes[~~(Math.random()*classes.length)]);
		$(this).addClass(classes[~~(Math.random()*classes.length)]);
	});
}



// Particles by Zed Dash https://codepen.io/z-/pen/bpxgWZ
function initparticles() {
   leaves();
}

function leaves() {
   $.each($(".tree"), function(){
      var heartcount = ($(this).width()/20)*5;
      for(var i = 0; i <= heartcount; i++) {
         var size = ($.rnd(60,120)/10);
         $(this).append('<span class="particle" style="left:' + $.rnd(-70,70) + 'px;width:' + size + 'px; height:' + size + 'px;animation-delay: ' + ($.rnd(0,30)/10) + 's;"></span>');
      }
   });
}

jQuery.rnd = function(m,n) {
      m = parseInt(m);
      n = parseInt(n);
      return Math.floor( Math.random() * (n - m + 1) ) + m;
}

initparticles();


// hide ui
$(document).on('keydown', keydown).on('keyup', keyup);
var uis = 0;
function keydown(e) {
  var key = e.which;
	
  if(key === 32) {
		if (uis == 0) {
			$('.ui').css('opacity', '0');
			uis = 1;
		} else {
			$('.ui').css('opacity', '1');
			uis = 0;
		}
  }
}
            
          
!
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