Pen Settings



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


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


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.


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.


                <div class="attr">
	<h6>Text by Apple. Photo by Aniket Deole @ Unsplash</h6>


                $blur: 10;
$bg_size: 800;

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

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

body {
	background: url('{$bg_size}') 50% no-repeat fixed;
	// background: url('') 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 ="body").selectAll("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; });

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

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

function started(event, d) {
	console.log("drag start");
	var dragElem ="dragging", true);
	// Z-index switch - needs improvement"z-index", -1);"z-index", 100);

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

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

	function ended() {
		console.log("drag stop");
		dragElem.classed("dragging", false);