Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                <header class="desktop-header">
	<div>
	<h1 class="desktop-title">ANP</h1>
	<nav class="desktop-nav">
		<a href="#1">About</a>
		<a href="#1">Options</a>
	</nav>
	</div>
	<nav class="desktop-social">
		<span id="clock">13:21</span>
	</nav>
</header>
<div class="window window-1 draggable">
	<header class="window-header"></header>
	<div class='dragbar-right' id="resize-right"></div>
	<div class='dragbar-left' id="resize-left"></div>
	<div class='dragbar-bottom' id="resize-bottom"></div>
	<div class="window-content">
<h1 id='headline'>A Nice Pair</h1>
		</div>
</div>

<div class="window draggable window-2">
	<header class="window-header">
		<nav class="window-controls">
		<a href='#1' id="close-button" class="window-control-close">
			<svg>
		    <path fill="#000000" d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" />
</svg>
		</a>
		</nav>
	</header>
	<div class='dragbar-right' id="resize-right"></div>
	<div class='dragbar-left' id="resize-left"></div>
	<div class='dragbar-bottom' id="resize-bottom"></div>
	<div class="window-content">
<h1 id='headline'>A Nice Pair</h1>
		</div>
</div>

<div class="window window-countdown draggable">
	<header class="window-header">
		<h2 class="window-title">Time to Private View</h2>
	</header>
	<div class='dragbar-right' id="resize-right"></div>
	<div class='dragbar-left' id="resize-left"></div>
	<div class='dragbar-bottom' id="resize-bottom"></div>
	<div class="window-content">
<h1 id='time-string'>1d 2h 4m</h1>
		</div>
</div>
              
            
!

CSS

              
                $dragbar-width: 3px;
$blue: #268Aff;
$black: rgb(20,20,20);
$green: #12ff6a;

* {
	box-sizing: border-box;
}

body {
	background: lightgray;
	font-family: acumin-pro, serif;
}

.window {
	position: absolute;
	border-radius: 3px;
	resize: both;
	border-top: $dragbar-width solid $black;
	overflow: hidden;
	box-shadow: -10px 10px 0 0 rgba(black, .2);
	&.closed {
		transition: 500ms;
		opacity: 0;
		transform: translateY(-100px);
		pointer-events: none;
	}
}

.window-1 {
	left: 2rem;
	top: 60px;
	background: $blue;
	width: 440px;
	height: 300px;

}

.window-2 {
	left: 200px;
	top: 100px;
	width: 540px;
	height:350px;
	background: $green;
	
}
.window-countdown {
	left: auto;
	right: 100px;
	top: auto;
	bottom: 10%;
	width: 480px;
	height:150px;
	background: white;	
}

.window-content {
	max-height: calc(100% - 20px);
	overflow-y: auto;
	padding: 1rem;
	margin-right: $dragbar-width;
	margin-bottom: $dragbar-width;
	h1 {
		font-size: 4rem;
	}
}

.window-header {
	background: white;
	min-height: 20px;
	padding: 5px 10px;
	display: flex;
	justify-content: flex-end;
	border-bottom: $dragbar-width solid $black;
	width: 100%;
	cursor: grab;
	.is-pointer-down & {
		cursor: grabbing;
	}
	&:hover, &:focus {
		background: darken(white, 10)
	}
}

.window-title {
	font-size: .9rem;
	font-weight: 600;
	
}

.window-controls {}

[class*=window-control]{
	display: inline-block;
	height: 100%;
	line-height: 0;
	cursor: pointer;
	svg {
		position: relative;
		top: -2px;
		height: 20px;
		width: 20px;
	}
	
}

[class*=dragbar] {
	position: absolute;
	background: $black;
}
.dragbar-right {
	right: 0;
	top: 0;
	width: $dragbar-width;
	height: 100%;
	cursor: ew-resize;
}
.dragbar-bottom {
	bottom: 0;
	left: 0;
	height: $dragbar-width;
	width: 100%;
	cursor: ns-resize;
}
.dragbar-left {
	bottom: 0;
	left: 0;
	width: $dragbar-width;
	height: 100%;
	cursor: ew-resize;
}

//DESKTOP LEVEL STUFF
.desktop-header {
	background: #fff;
	border-bottom: 1px solid $black;
	display: flex;
	font-size: 1.1rem;
	justify-content: space-between;
	padding: 10px;
	
	a {
		color: $black;
		text-decoration: none;
	}
}

.desktop-title {
	font-weight: bold;
	margin-right: 2rem;
	display: inline-block;
}

.desktop-nav {
	display: inline-block;
	a {
		margin-right: .5rem;
	}
}

.dektop-social {
}
              
            
!

JS

              
                // if you have multiple .draggable elements
// get all draggie elements
var draggableElems = document.querySelectorAll(".draggable");
// array of Draggabillies
var draggies = [];
// init Draggabillies
for (var i = 0, len = draggableElems.length; i < len; i++) {
	var draggableElem = draggableElems[i];
	var draggie = new Draggabilly(draggableElem, {
		handle: ".window-header"
	});
	draggies.push(draggie);
}
var activeWindow = document.querySelector('.window');
var windows = document.querySelectorAll(".window");

var handleClose = function(e){
	activeWindow.classList.toggle('closed')
}

var handleMouseX = function(e) {
//	console.log(e);
	var pos = activeWindow.getBoundingClientRect();
	activeWindow.style.width = e.pageX - pos.left + "px";
};
var handleMouseXLeft = function(e) {
	var pos = activeWindow.getBoundingClientRect();
	console.log('l')
	activeWindow.style.left = e.pageX + "px";
	activeWindow.style.width = pos.right - e.pageX + "px";
};

var handleMouseY = function(e) {
	var pos = activeWindow.getBoundingClientRect();
	activeWindow.style.height = e.pageY - pos.top + "px";
};


var handleDrag = function(e) {
	e.preventDefault();
	if(e.srcElement.id === 'resize-right'){
		document.addEventListener("mousemove", handleMouseX, false);
	} else if (e.srcElement.id === 'resize-left'){
		console.log('yp')
		document.addEventListener("mousemove", handleMouseXLeft, false);
	} else {
			document.addEventListener("mousemove", handleMouseY, false);
	}
};

document.addEventListener("mouseup", function(e) {
	console.log("up");
	document.removeEventListener("mousemove", handleMouseX, false);
	document.removeEventListener("mousemove", handleMouseY, false);
	document.removeEventListener("mousemove", handleMouseXLeft, false);
});

var init = function(){
	for (var i = 0; i < windows.length; i++){
		var w = windows[i];
		console.log(w);
		var resizeRight = w.querySelector('#resize-right')
		resizeRight.addEventListener("mousedown", handleDrag, false);
		var resizeLeft = w.querySelector('#resize-left')
		resizeLeft.addEventListener("mousedown", handleDrag, false);
		var resizeBottom = w.querySelector("#resize-bottom");
		resizeBottom.addEventListener("mousedown", handleDrag, false);
		var closeButton = w.querySelector("#close-button");
		if(closeButton){
		closeButton.addEventListener("click", handleClose, false);
		}
		w.addEventListener("mousedown", function(e){
			activeWindow.style.zIndex = 0;
			activeWindow = e.srcElement.closest('.window');
			activeWindow.style.zIndex = 10;
		})
		console.log(activeWindow)
	}
}

init();

var setTimer = function(){
	var timeString = document.getElementById('time-string')
	var now = Date.now();
	var openingDate = Date.parse('2017-06-19 18:00:00');
	var timespan = countdown(now, openingDate);
	timeString.innerHTML = timespan.days + 'd ' + timespan.hours + 'h ' + timespan.minutes + 'm ' + timespan.seconds + 's';
}
var setClock = function(){
	var clockEl = document.getElementById('clock')
	var now = new Date();
   var h = now.getHours();
   var m = now.getMinutes();
	clockEl.innerHTML = h + ':' + m;
}
setTimer();
setClock();
window.setInterval(setTimer, 1000)
window.setInterval(setClock, 60000)
              
            
!
999px

Console