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="box">
	<p class="aspect"></p>
	<dl>
		<dt>width</dt>
		<dd id="w"></dd>
	</dl>
	<dl>
		<dt>height</dt>
		<dd id="h"></dd>
	</dl>
	<p class="not"></p>
</div>
            
          
!
            
              @import url("https://fonts.googleapis.com/css?family=Roboto:100,400,400i,700");
html, * {
	font-family: 'Roboto';
}
html, body {
	height: 100%;
	min-height: 100%;
}

// media
// ---------------------------------------------------------
$w_ipad_landscape: 1024px;
$w_ipad_portrait: 768px;
$w_ipad_pro_landscape: 1366px;
$w_ipad_pro_portrait: 1024px;
$w_iphone_plus_portrait: 414px;
$w_iphone_portrait: 375px;
$w_iphone_X_landscape: 812px; // display
$w_iphone_X_landscape: 724px; // iOS Safari

$portrait: 'max-aspect-ratio: 3/2';
$landscape: 'min-aspect-ratio: 3/2';

@mixin screen($target: null) {

	@if $target == sp {
		@media
		only screen and (max-width: $w_iphone_plus_portrait) and ($portrait),
		only screen and (max-height: $w_iphone_plus_portrait) and ($landscape) {
			@content;
		}
	}

	@if $target == _sp {
		@media
		only screen and (min-width: $w_iphone_plus_portrait + 1) and ($portrait),
		only screen and (min-height: $w_iphone_plus_portrait + 1) and ($landscape) {
			@content;
		}
	}

	@if $target == tb {
		@media
		only screen and (min-width: $w_iphone_plus_portrait + 1) and (max-width: $w_ipad_pro_portrait) and ($portrait),
		only screen and (min-height: $w_iphone_plus_portrait + 1) and (max-height: $w_ipad_portrait) and ($landscape) {
			@content;
		}
	}

	@if $target == pc {
		@media
		only screen and (min-width: $w_ipad_pro_portrait + 1) and ($portrait),
		only screen and (min-height: $w_ipad_portrait + 1) and ($landscape) {
			@content;
		}
	}

	@if $target == _pc {
		@media
		only screen and (max-width: $w_ipad_pro_portrait) and ($portrait),
		only screen and (max-height: $w_ipad_portrait) and ($landscape) {
			@content;
		}
	}
	
	@if $target == p {
		@media
		only screen and ($portrait) {
			@content;
		}
	}
	@if $target == l {
		@media
		only screen and ($landscape) {
			@content;
		}
	}

}

// ---------------------------------------------------------
.box {
	height: 100%;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-direction: column;
	
	&::before {
		display: block;
		font-size: 2rem;
		font-weight: 100;
		
		@include screen(sp) {
			content: 'Smart phone';
		}
		@include screen(tb) {
			content: 'Tablet';
		}
		@include screen(pc) {
			content: 'PC';
		}
	}
	
	p {
		margin: 1rem 0;
		font-size: 1rem;
		font-weight: 100;
		
		&::before,
		&::after {
			display: block;
		}
		
		&.not {
			&::before {
				@include screen(_sp) {
					content: 'not Smart phone';
				}
			}
			&::after {
				@include screen(_pc) {
					content: 'not PC';
				}
			}
		}
		
		&.aspect {
			&::before {
				@include screen(p) {
					content: '|| Portrait ||';
				}
			}
			&::after {
				@include screen(l) {
					content: '= Landscape =';
				}
			}
		}
	}
	
	dl {
		display: flex;
		justify-content: space-between;
		min-width: 8rem;
		margin: .25rem 0;
		text-align: left;
		
		border-bottom: 1px solid #ccc;
		
		dt, dd {
			display: inline-block;
			padding: .2rem .5rem;
		}
		
		dt {
			font-weight: bold;
			&::after {
				content: ':';
			}
		}
		dd {
			text-align: right;
			
			&::after {
				content: 'px';
				margin-left: .2rem;
			}
			
		}
	}
	
}
            
          
!
            
              (function(){
	const size = {
		w: document.getElementById('w'),
		h: document.getElementById('h')
	};
	const h = document.getElementById('box');
	const get_size = function() {
		var w = window.innerWidth;
		var h = window.innerHeight;
		size.w.innerHTML = w;
		size.h.innerHTML = h;
	};
	window.addEventListener('resize', get_size, false);
	get_size();
})();

            
          
!
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