Pen Settings

HTML

CSS

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

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

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.

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>
	<h1>The Polar Bear</h1>

	<div class="warning">
		<p>⚠️ Your browser does not support Container Queries, so this demo won't work. If you're feeling adventurous use Chromium 91.0.4459.0 with “Enable CSS Container Queries” enabled. Alternatively you can <a href="https://codepen.io/bramus/pen/RwKOVRG" target="_top">check a version that uses a polyfill</a> or <a href="https://brm.us/container-queries-demo" target="_top">watch a recording of this demo in action</a>.</p>
	</div>

	<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer mattis turpis eu neque tincidunt lacinia. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam auctor ultrices tortor et volutpat. Donec eu semper orci, eu fermentum orci. Vivamus aliquam lobortis egestas. Proin vel mauris vitae sem auctor cursus. Aenean sit amet odio at magna pharetra luctus nec eget urna. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Praesent in leo at tellus ultricies laoreet.</p>

	<div class="animalcards">
		<div class="animalcard-wrapper">
			<div class="animalcard">
				<div class="animalcard__image">
					<img src="https://source.unsplash.com/PX_1j-M59I8" alt="Photo of a polar bear walking" width="1080" height="720" />
					<a href="https://unsplash.com/photos/PX_1j-M59I8" target="_blank">Polar bear walking</a> by <a href="https://unsplash.com/@dtbosse" target="_blank">Daniel Bosse</a>
				</div>
				<div class="animalcard__description">
					<p>The polar bear <em>(Ursus maritimus)</em> is a hypercarnivorous bear whose native range lies largely within the Arctic Circle, encompassing the Arctic Ocean, its surrounding seas and surrounding land masses. It is the largest extant bear species, as well as the largest extant land carnivore.</p>
				</div>
			</div>
		</div>
		<div class="animalcard-wrapper">
			<div class="animalcard">
				<div class="animalcard__image">
					<img src="https://source.unsplash.com/PX_1j-M59I8" alt="Photo of a polar bear walking" width="1080" height="720" />
					<a href="https://unsplash.com/photos/PX_1j-M59I8" target="_blank">Polar bear walking</a> by <a href="https://unsplash.com/@dtbosse" target="_blank">Daniel Bosse</a>
				</div>
				<div class="animalcard__description">
					<p>The polar bear <em>(Ursus maritimus)</em> is a hypercarnivorous bear whose native range lies largely within the Arctic Circle, encompassing the Arctic Ocean, its surrounding seas and surrounding land masses. It is the largest extant bear species, as well as the largest extant land carnivore.</p>
				</div>
			</div>
		</div>
		<div class="animalcard-wrapper">
			<div class="animalcard">
				<div class="animalcard__image">
					<img src="https://source.unsplash.com/PX_1j-M59I8" alt="Photo of a polar bear walking" width="1080" height="720" />
					<a href="https://unsplash.com/photos/PX_1j-M59I8">Polar bear walking</a> by <a href="https://unsplash.com/@dtbosse">Daniel Bosse</a>
				</div>
				<div class="animalcard__description">
					<p>The polar bear <em>(Ursus maritimus)</em> is a hypercarnivorous bear whose native range lies largely within the Arctic Circle, encompassing the Arctic Ocean, its surrounding seas and surrounding land masses. It is the largest extant bear species, as well as the largest extant land carnivore.</p>
				</div>
			</div>
		</div>
	</div>

	<p>Nam pulvinar congue condimentum. Pellentesque fringilla ante sed massa tincidunt feugiat. Nulla bibendum est eros, non malesuada dolor vehicula in. Morbi eu cursus arcu. Phasellus ultricies ornare lorem, non interdum orci condimentum eu. Donec condimentum condimentum ligula ut placerat. Vestibulum id neque condimentum, molestie nunc vel, suscipit turpis. Quisque orci velit, mattis et nibh non, tempor finibus erat. Nullam tristique, tortor non commodo cursus, magna turpis rhoncus leo, quis porta quam ante sed orci. Nunc vehicula imperdiet leo in vulputate. Quisque quis dolor orci.</p>

	<p>Curabitur ultrices fringilla libero sit amet porta. Nulla rhoncus venenatis euismod. Praesent non interdum sem. Nunc in nibh tincidunt, faucibus sem at, finibus turpis. Nullam vel odio blandit, tincidunt urna et, luctus lectus. Vivamus porta sem vitae turpis interdum porta eu id ligula. Fusce non nisi fringilla, malesuada metus ut, imperdiet ligula. Nunc quis lorem nibh. Duis pharetra magna vestibulum metus convallis, id mollis ligula vulputate. Sed purus est, consectetur non suscipit sit amet, hendrerit at dolor. Maecenas feugiat, quam vel ullamcorper feugiat, sapien ipsum viverra justo, id cursus metus nisi quis enim.</p>

	<h2>Aenean ac pellentesque ante</h2>

	<div class="animalcard-wrapper">
		<div class="animalcard">
			<div class="animalcard__image">
				<img src="https://source.unsplash.com/PX_1j-M59I8" alt="Photo of a polar bear walking" width="1080" height="720" />
				<a href="https://unsplash.com/photos/PX_1j-M59I8" target="_blank">Polar bear walking</a> by <a href="https://unsplash.com/@dtbosse" target="_blank">Daniel Bosse</a>
			</div>
			<div class="animalcard__description">
				<p>The polar bear <em>(Ursus maritimus)</em> is a hypercarnivorous bear whose native range lies largely within the Arctic Circle, encompassing the Arctic Ocean, its surrounding seas and surrounding land masses. It is the largest extant bear species, as well as the largest extant land carnivore.</p>
			</div>
		</div>
	</div>

	<p>Nam pulvinar congue condimentum. Pellentesque fringilla ante sed massa tincidunt feugiat. Nulla bibendum est eros, non malesuada dolor vehicula in. Morbi eu cursus arcu. Phasellus ultricies ornare lorem, non interdum orci condimentum eu. Donec condimentum condimentum ligula ut placerat. Vestibulum id neque condimentum, molestie nunc vel, suscipit turpis. Quisque orci velit, mattis et nibh non, tempor finibus erat. Nullam tristique, tortor non commodo cursus, magna turpis rhoncus leo, quis porta quam ante sed orci. Nunc vehicula imperdiet leo in vulputate. Quisque quis dolor orci.</p>

	<div class="inset">
		<div class="animalcard-wrapper">
			<div class="animalcard">
				<div class="animalcard__image">
					<img src="https://source.unsplash.com/PX_1j-M59I8" alt="Photo of a polar bear walking" width="1080" height="720" />
					<a href="https://unsplash.com/photos/PX_1j-M59I8" target="_blank">Polar bear walking</a> by <a href="https://unsplash.com/@dtbosse" target="_blank">Daniel Bosse</a>
				</div>
				<div class="animalcard__description">
					<p>The polar bear <em>(Ursus maritimus)</em> is a hypercarnivorous bear whose native range lies largely within the Arctic Circle, encompassing the Arctic Ocean, its surrounding seas and surrounding land masses. It is the largest extant bear species, as well as the largest extant land carnivore.</p>
				</div>
			</div>
		</div>
	</div>

	<p>Curabitur ultrices fringilla libero sit amet porta. Nulla rhoncus venenatis euismod. Praesent non interdum sem. Nunc in nibh tincidunt, faucibus sem at, finibus turpis. Nullam vel odio blandit, tincidunt urna et, luctus lectus. Vivamus porta sem vitae turpis interdum porta eu id ligula. Fusce non nisi fringilla, malesuada metus ut, imperdiet ligula. Nunc quis lorem nibh. Duis pharetra magna vestibulum metus convallis, id mollis ligula vulputate. Sed purus est, consectetur non suscipit sit amet, hendrerit at dolor. Maecenas feugiat, quam vel ullamcorper feugiat, sapien ipsum viverra justo, id cursus metus nisi quis enim.</p>

	<p>Duis nec nisi a eros dictum euismod nec non enim. Donec augue neque, aliquam id finibus a, volutpat ut ligula. Nam feugiat odio elit, ut molestie mi tempus vel. Etiam vitae velit eget massa scelerisque hendrerit cursus vel justo. Sed eget euismod lectus. Morbi tincidunt diam ac diam tempor molestie. Mauris eget lectus leo. Etiam id porta turpis.</p>
</main>
              
            
!

CSS

              
                /* Non-essential .animalcard styles */
.animalcard {
	align-content: start;
	border: 1px solid #ccc;
	background: rgba(0, 0, 0, 0.05);
}
.animalcard__image {
	grid-area: image;
	font-size: 0.5em;
	font-style: italic;
	text-align: center;
}
.animalcard__description {
	grid-area: description;
	font-size: 0.9em;
	text-align: center;
}
.animalcard > * > :first-child {
	margin-top: 0;
}
.animalcard > * > :last-child {
	margin-bottom: 0;
}

/** Container Queries in Action: If enough space is available, place image next to description **/
.animalcard-wrapper {
	contain: layout inline-size style;
}
.animalcard { /* SMALL LAYOUT: Image stacked on top of Description */
	display: grid;
	grid-template: "image" "description" / 1fr;
	gap: 1em;
	padding: 1em;
}
@container (min-width: 30rem) { /* MEDIUM LAYOUT: Image next to Description (1fr each) */
	.animalcard {
		gap: 2em;
		padding: 2em;
		grid-template: "image description" / 1fr 1fr;
	}

	.animalcard__description {
		text-align: left;
	}
}
@container (min-width: 70rem) { /* LARGE LAYOUT: Large Image next to Description */
	.animalcard {
		grid-template-columns: 2fr 1fr;
	}
}

/* Set of animalcards: Place nested elements next to eachother */
.animalcards {
	display: grid;
	gap: 1em;
	grid-template-columns: repeat(auto-fit, minmax(10em, 1fr));
}

/* Inset in content */
.inset {
	width: 100%;
	max-width: 55rem;
	margin: 1em 1em 1em 0;
}
@media(min-width: 55rem) {
	.inset {
		float: left;
	}
}





/* Show/Hide Warning if no container Queries Support */
@supports (contain: block-size) {
	.warning {
		display: none;
	}
}
.warning {
	padding: 1em;
	border: 1px solid #ccc;
	background: rgba(255 255 205 / 0.8);
}
.warning p {
	margin: 0;
	padding: 0;
}

/* NON ESSENTIAL STYLES BELOW */
html,
body {
	margin: 0;
	padding: 0;
	background: #fff;
}

body {
	font-size: clamp(1.1em, calc(0.5em + 1vw), 2.5em);
	line-height: 1.42;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen",
		"Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif;
}

main {
	font-weight: 300;
	width: 90vw;
	max-width: 80rem;
	margin: 0 auto;
	padding: 4em 0;
}

main > * {
	margin: 0;
}
main > * + * {
	margin-top: 1em;
}

main img {
	width: 100%;
	height: auto;
}

.full-bleed {
	--source: "https://brm.us/full-bleed";
	width: 100vw;
	margin-left: 50%;
	transform: translateX(-50%);
}

.text-center {
	text-align: center;
}

              
            
!

JS

              
                
              
            
!
999px

Console