JavaScript preprocessors can help make authoring JavaScript easier and more convenient. For instance, CoffeeScript can help prevent easy-to-make mistakes and offer a cleaner syntax and Babel can bring ECMAScript 6 features to browsers that only support ECMAScript 5.
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.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
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();
})();
Also see: Tab Triggers