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

              
                <main class="page">
	<div class="card">
		<header>
			<span class="card-title">Card title</span>
		</header>
		<section>
			<span class="card-body">
				Lorem ipsum dolor sit amet, an eripuit ornatus comprehensam pro. Ignota eirmod eleifend vix te, nec ne corpora mnesarchum.
			</span>
		</section>
	</div>
	<span class="instructions">Change your OS color scheme to observe effect</span>
</main>
              
            
!

CSS

              
                /* 
	Define a palette mapping specific to branding/style-guide
	colors for your app or product.
*/
$palette: (
	"black": #11120e,
	"white": #fff,
	"blue": #0973d6,
	"orange": #ff9a1f
);

/*
	Maps themed colors to CSS custom prop names, as defined
	by the theme map's key. Colors reference our $palette map,
	but can also be defined directly after each custom prop key.
*/
$dark-theme: (
	background-0: map-get($palette, "black"),
	background-1: desaturate(lighten(map-get($palette, "black"), 5%), 50%),
	background-2: desaturate(lighten(map-get($palette, "black"), 12%), 35%),
	neutral: desaturate(lighten(map-get($palette, "black"), 50%), 28%),
	foreground: map-get($palette, "white"),
	primary: map-get($palette, "orange")
);

$light-theme: (
	background-0: map-get($palette, "white"),
	background-1: desaturate(lighten(map-get($palette, "black"), 88%), 10%),
	background-2: desaturate(lighten(map-get($palette, "black"), 80%), 20%),
	neutral: desaturate(lighten(map-get($palette, "black"), 30%), 28%),
	foreground: map-get($palette, "black"),
	primary: map-get($palette, "blue")
);

/* 
	Iterates through $theme-map and returns the key as
	a CSS custom property name, and extracts each primary
	component to be expressed as a comma-separated string
*/
@mixin map-css-custom-props-by-theme($theme) {
	@each $color-key, $color in $theme {
		--color-#{$color-key}: #{red($color), green($color), blue($color)};
	}
}

/*
	Color function which receives a CSS custom property name, and
	optionally an opacity coefficient, to convert to a CSS color
	expressed in rgba(r,g,b,a) format. 

	NOTE: CSS custom props are defined as a string of the r,g,b components,
	not as a valid CSS/Sass color.

	ALSO NOTE: Within Legacy Sass/SCSS, RGBA() != rgba(). RGBA() refers 
	to the CSS function, not the built-in rgba() Sass function. The CSS 
	RGBA() function is required for this mapping to work. 
*/
@function rgba-color($color-key, $opacity: 1) {
	@return RGBA(var(--color-#{$color-key}), $opacity);
}

:root {
	// use system fonts: as found on github
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
		Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";

	// font sizes with minimal breakpoint support via media query
	font-size: 16px;
	@media screen and (min-width: 480px) {
		font-size: 20px;
	}

	// By default, map dark-mode theme variables
	@include map-css-custom-props-by-theme($dark-theme);
	// If user prefers light theme, apply light-theme variables instead
	@media (prefers-color-scheme: light) {
		@include map-css-custom-props-by-theme($light-theme);
	}
}

.page {
	position: relative;
	box-sizing: border-box;
	padding: 1rem;
	width: 100vw;
	height: 100vh;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	background-color: rgba-color(background-1);
}

.card {
	box-sizing: border-box;
	border-radius: 0.5em;
	border-style: solid;
	border-width: 4px;
	border-color: rgba-color(background-2);
	background-color: rgba-color(background-0);
	padding: 1rem 1.5rem;
	width: 100%;
	max-width: 24em;
	// rgba-color function can be used inline with more complex statements
	box-shadow: 0 0.4rem 0.4rem rgba-color(background-0, 0.33);
	// box shadow must reference a different custom property in light mode
	@media (prefers-color-scheme: "light") {
		box-shadow: 0 0.4rem 0.4rem rgba-color(dark-0, 0.05);
	}

	header {
		margin-bottom: 0.5rem;
	}
}

.card-title {
	color: rgba-color(primary);
	font-size: 1.375rem;
	font-weight: 400;
	line-height: 1.5;
	margin-bottom: rem;
	text-transform: capitalize;
}

.card-body {
	color: rgba-color(foreground);
	font-size: 1rem;
	font-weight: 400;
	line-height: 1.5;
}

.instructions {
	color: rgba-color(neutral);
	font-size: 0.75rem;
	margin-top: 1rem;
	box-sizing: border-box;
}

              
            
!

JS

              
                
              
            
!
999px

Console