cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <div class="attr">
	<h6>Text by <a href="https://www.apple.com/osx/preview/design/">Apple</a>. Photo by DAVID ILIFF. License: CC-BY-SA 3.0</h6>
</div>
            
          
!
            
              $blur: 10;

*, *:before {
	box-sizing: border-box;
	position: relative;
}

html, body {
	margin: 0;
	padding: 0;
}

body {
	background: url('http://upload.wikimedia.org/wikipedia/commons/d/d6/Half_Dome_from_Glacier_Point%2C_Yosemite_NP_-_Diliff.jpg') 50% no-repeat fixed;
	background-size: cover;
	font: 14px/1.4 'HelveticaNeue-Light', 'Helvetica Neue Light', 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
}

h2 {
	font-size: 1.4em;
	font-weight: 300;
	color: #222;
}
p:not(:last-child) {
	margin-bottom: 0.6em;
}
p.small {
	font-size: 0.8em;
	color: #222;
	text-align: center;
}
a {
	text-decoration: none;
	color: inherit;
	border-bottom: 1px solid #888;
}

article {
	position: absolute;
	background: inherit;
	border: 1px solid rgba(0,0,0,0.1);
	border-radius: 6px;
	box-shadow: 0 8px 16px rgba(0,0,0,0.25);
	overflow: hidden;

	&:before {
		content: '';
		position: absolute;
		top: -$blur * 2px; 
		left: -$blur * 2px; 
		right: -$blur * 2px; 
		bottom: -$blur * 2px;
		background: inherit;
		filter: blur($blur * 1px) saturate(2);
	}
	
	&.dragging {
		&:before {
			filter: blur($blur * 1px) sepia(1) hue-rotate(200deg);
		}
		.title {
			background: rgba(215,225,255,0.85);
		}
	}

	.title {
		padding: 8px;
		background: rgba(235,235,235,0.85);
		border-bottom: 1px solid rgba(0,0,0,0.1);
		text-align: center;

		&:hover {
			cursor: move;
		}
	}

	.content {
		padding: 8px;
		background: rgba(255,255,255,0.66);
	}
}

.attr {
	position: fixed;
	right: 5px;
	bottom: 5px;
	font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif;
	font-size: 0.8em;
	font-weight: normal;
	color: white;
	text-align: right;
}
            
          
!
            
              var drag = d3.drag()
	.on("start", started),

	data = [
		{x: 40, y: 40, w: 250, title: "Drag me", text: "Thoughtfully redesigning OS X meant going deep into every aspect of the interface and focusing on details large and small. There are obvious changes to big things, like translucency in windows and streamlined toolbars. And there are more subtle changes to a lot of small things, like the buttons, icons, and font you see throughout the system. The more you use your Mac, the more you’ll notice, and the more you’ll love it."},
		{x: 170, y: 310, w: 300, title: "Drag me", text: "By adding translucency to certain interface elements in OS X Yosemite, we’ve put a greater emphasis on your content. Translucent toolbars let you know there’s more to see than what’s visible in the window as you scroll. And a translucent sidebar lets you see what’s hidden behind the active window. So the interface takes on the look of your desktop image and your content — making your Mac experience different from anyone else’s."},
		{x: 400, y: 80, w: 300, title: "Info", text: "Try dragging windows around. Have fun!"}
	],

	winElems = d3.select("body").selectAll("article")
		.data(data)
		.enter()
		.append("article")
		.attr("class", "draggable")
		.style("left", function(d) { return d.x + "px"; })
        .style("top", function(d) { return d.y + "px"; })
		.style("width", function(d) { return d.w + "px"; })
		.style("z-index", function(d,i) { return i; });

winElems
	.append("div")
	.attr("class", "title")
	.html(function(d) { return "<h2>" + d.title + " </h2>"; });

winElems
	.append("div")
	.attr("class", "content")
	.html(function(d) { return "<p>" + d.text + " </p>"; });

winElems.call(drag);

function started() {
	console.log("drag start");
	var dragElem = d3.select(this).classed("dragging", true);
	
	// Z-index switch - needs improvement
	winElems.style("z-index", -1);
	dragElem.style("z-index", 100);

	d3.event.on("drag", dragged).on("end", ended);

	function dragged(d) {
		d.x = d3.event.x;
		d.y = d3.event.y;
		dragElem
			.style("left", d.x + "px")
			.style("top", d.y + "px");
	}

	function ended() {
		console.log("drag stop");
		dragElem.classed("dragging", false);
	}
}
            
          
!
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