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

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

              
                <div class="a-pull-3 a-wrapper u-text-align-center">
	<h3 class="a-pull-up-above-item u-border-a-1 u-margin-tb-0">Some text</h3>
	<div class="c-box">
		<img class="a-pull-up-item" src="http://placehold.it/300x200" alt="Placeholder image">
		<p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Quod impedit consequuntur repudiandae? Aliquam architecto veritatis ratione vero hic, quibusdam odit, harum veniam eum sapiente atque, obcaecati similique corrupti autem sint!</p>
	</div>
</div>
              
            
!

CSS

              
                /* 
The Pull algorithm "pulls" an element outside of the box 
its containing element. It can be useful achieving a slight
"bleed" of one element over (or under) it's containing element.

What do you call this effect?
*/


* {
/* 	box-sizing: border-box; */
}

/* 
Set the custom property on an element containing all 
relevant pull elements.
*/
.a-pull-3 { 
	--a-pull-size: 3; 
}

/*
Add this to the item that will be "pulled up"
*/
.a-pull-up-item {
	margin-top: calc( var( --a-pull-size ) * -1rem );
}

/* 
Add this to the element that is the next block level element
above the item that will be "pulled up"
*/
.a-pull-up-above-item {
	padding-bottom: calc( var( --a-pull-size ) * 1rem );
}







/* Not part of the algorithm */

.c-box {
	background-color: magenta;
	color: white;
	display: flex;
	flex-direction: column;
	padding-left: 1rem;
	padding-right: 1rem;
}

.a-wrapper {
	max-width: 400px;
	margin-left: auto;
	margin-right: auto;
}

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

.u-border-a-1 {
	border: 3px solid skyblue;
}

.u-margin-tb-0 {
	margin-top: 0;
	margin-bottom: 0;
}
              
            
!

JS

              
                
describe( '.a-pull', () => {
	const pullSize = getCustomPropertyValue( '.a-pull-3', '--a-pull-size' );
	const pullItem = $( '.a-pull-up-item' ).getBoundingClientRect();
	const pullItemDirectParent = $( '.a-pull-up-item' ).parentElement.getBoundingClientRect();
	const itemAbovePullItem = $( '.a-pull-up-above-item' ).getBoundingClientRect();
	
	it( 'pulls a box up, above its direct parent', () => {
		return assertGreaterThan( pullItem.top.toFixed(), pullItemDirectParent.top.toFixed() );
	});
	
	it( 'the above-item increases in height by the pull-size value', () => {
		return assertEquals( pullItem.top.toFixed(), itemAbovePullItem.bottom.toFixed() );
	});

});











function describe( testString, tests ) {
	console.group( testString );
	tests();
	console.groupEnd();
}

function it( testString, test ) {
	let testResult = test();
	let color = ( false === testResult.result ) ? 'red' : 'green';

	console.log( `%c ${testString} ${testResult.message}`, `color:${color}` );
}

function assertEquals( value1, value2 ) {
	let message = '';
	let expression = value1 % value2 < 1;

	if ( false === expression ) {
		message = '\n \t Fail: ' + (value1 % value2).toFixed(1);
	}

	return {
		result: expression,
		message: message
	};
}

function assertGreaterThan( value1, value2 ) {
	let message = '';
	let expression = value1 > value2;

	if ( false === expression ) {
		message = '\n \t Fail: ' + (value1 % value2).toFixed(1);
	}

	return {
		result: expression,
		message: message
	};
}

function $( selector ) {
	return document.querySelector( selector );
}

function getCustomPropertyValue( selector, propertyName ) {
	return window.getComputedStyle( $( selector ) ).getPropertyValue( propertyName );
}
              
            
!
999px

Console