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

              
                
    <h1>
      <span class="L">
        Asymmetric
      </span>
      <span class="C">
		Layout
      </span>
      <span class="R">
		Container
      </span>
    </h1>
    
    
    <div id="app-explanation" class="explanation" :style="outsideMargen">
    
    <div class="container">
      
      <div class="txt-mr" :data-text="m"></div>
        <div class="txt-width" :data-text="m" :style="{ width: width }">
          width:{{ width }}
        </div>
      <div class="txt-maxwidth" data-text="" :style="{ width: maxWidth }">
        max-width: calc(100% - (<strong>50% - {{ half }}</strong
          >))
        </div>
        
        <div class="txt-border" :data-text="'border-left: ' + m + ' + ' + p" :style="{ width: border }"></div>
        <div
        class="txt-padding"
        :data-text="'padding-left: ' + padding"
        :style="{ left: border, width: padding }"
        ></div>
        
        <div class="sample" :style="styleset">
          <h2>Asymmetry column L</h2>
          <p>
            Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
            tempor incididunt ut labore et dolore magna aliqua.
          </p>
          <div
          class="mask"
          :style="{
            top: p,
            left: 'auto',
            right: p,
            bottom: p,
            maxWidth: 'calc(' + w + ' - ' + p + ' - ' + p + ')',
            width: 'calc(100% - ' + p + ')',
          }"
          ></div>
        </div>
      </div>
		
      <div class="container">
        <div class="txt-column" data-text="" :style="{ width: columnW }">
          width {{ columnW }}
        </div>
        <div class="txt-ml" :data-text="m"></div>
        <div class="txt-mr" :data-text="m"></div>
        
        <div class="txt-maxcolumn" data-text="" :style="{ width: w }">
          max-width {{ w }}
        </div>
        
        <div class="txt-50par" data-text="">50%</div>
        <div class="txt-columnhalf" data-text="" :style="{ width: half }">
          {{ half }}
        </div>
        <div
        class="txt-remainder"
        :data-text="'50% - ' + half"
        :style="{ width: remainder }"
        ></div>
        
        <div
        class="sample"
        :style="{
          maxWidth: w,
          width: columnW,
          padding: p,
          marginLeft: 'auto',
          marginRight: 'auto',
        }"
        >
        <h2>Normal column</h2>
        <p>
          Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod
          tempor incididunt ut labore et dolore magna aliqua.
        </p>
        
        <div class="mask" :style="{ top: p, left: p, right: p, bottom: p }"></div>
      </div>
    </div>
      
      <table>
        <tbody>
          <tr>
            <th>column width</th>
            <td><input type="text" v-model="w"></td>
          </tr>
          <tr>
            <th>column side margin</th>
            <td><input type="text" v-model="m"></td>
          </tr>
          <tr>
            <th>column padding</th>
            <td><input type="text" v-model="p"></td>
          </tr>
        </tbody>
      </table>
    </div>
    
    <div class="column asymmetry--l">
      <h2>Asymmetry L</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    
    <div class="column">
      <h2>Normal</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    
    <div class="column asymmetry--r">
      <h2>Asymmetry R</h2>
      <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
    </div>
    
    
    <div class="border">
      
      <div class="column asymmetry--l">
        <h2>Border L</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>
      
      <div class="column">
        <h2>Border</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>
      
      <div class="column asymmetry--r">
        <h2>Border R</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>
      
    </div>
    
    <div class="shadow">
      <div class="column asymmetry--l">
        <h2>Shadow L</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>
      
      <div class="column">
        <h2>Shadow</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>
      
      <div class="column asymmetry--r">
        <h2>Shadow R</h2>
        <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p>
      </div>
      
    </div>

              
            
!

CSS

              
                @import url('//fonts.googleapis.com/css?family=Roboto:100,400,700');
html, * { font-family: 'Roboto'; box-sizing: border-box; }

///////////////
// MIXIN ... Asymmetry column

@mixin asymmetry-column (
	$layout: c, // c: CENTER, l: LEFT, r: RIGHT 
	$w: 30em,	// clumn width
	$p: 0,		// column padding
	$m: 0,		// column side margin
	)
{	
	
	@if($m == 0) { $m: 0px; }
	@if($p == 0) { $p: 0px; }
	
	@if ($layout == c) { // CENTER
		
		max-width: $w;
		
		// 100% - [column side margin] - [column side margin]
		width: calc(100% - #{$m} - #{$m});

		margin-left: auto;
		margin-right: auto;
		padding: $p;
	
	}
	@else { // LEFT || RIGHT
		
		$max: calc(100% - (50% - (#{$w} / 2)));
		// 100% - (50% - [column half width] )
		
		$width: calc(100% - #{$m});
		// 100% - [column side margin]
		
		$padding: calc(50% - (#{$w} / 2) - #{$m});
		// 50% - [column half width] - [column side margin]
		
		$border: calc(#{$m} + #{$p});
		// [column side margin] + [column padding]
		
		@if ($layout == l) { // LEFT
			
			max-width: $max;
			width: $width;

			margin-left: 0;
			margin-right: auto;
			
			padding: $p;
			padding-left: $padding;

			border-left: solid transparent;
			border-left-width: $border;
		}
		@if ($layout == r) { // RIGHT

			max-width: $max;
			width: $width;
			margin-right: 0;
			margin-left: auto;
			
			padding: $p;
			padding-right: $padding;

			border-right: solid transparent;
			border-right-width: $border;
		}
		
	}
}

///////////////
// SAMPLE

$tw: 30rem;
$tm: 2rem;
$tp: 2rem;

////////// normal

.column {
	@include asymmetry-column($layout: c, $w: $tw, $m: $tm, $p: $tp);
	
	background: rgba(whitesmoke, .9);
}

.column + .column {
	margin-top: 2rem;
}

////////// asymmetry

.asymmetry--l {
	@include asymmetry-column($layout: l, $w: $tw, $m: $tm, $p: $tp);
}
.asymmetry--r {
	@include asymmetry-column($layout: r, $w: $tw, $m: $tm, $p: $tp);
}



///////////////
// round

.border {
	margin: 2rem 0;
	padding: 2rem 0;
	
	background: black;
	
	$r: 1.5rem;
	$bw: 0.3rem;
	$bc: yellowgreen;
	
	.column {
		border-radius: $r;
		background: white;

		box-shadow: inset 0 0 0 $bw $bc;
	}

	[class*='asymmetry'] {
		box-shadow: none;
		position: relative;

		&::before {
			content: '';
			position: absolute;
			top: 0;
			left: 0;
			right: 0;
			bottom: 0;
			pointer-events: none;
			box-shadow: none;
		}
	}

	.asymmetry--l {
		border-radius: 0 $r $r 0;

		&::before {
			border-radius: 0 $r $r 0;
			left: calc(#{$tm + $tp} * -1);
			box-shadow: 
				inset 0 #{$bw} 0 0 $bc,
				inset -#{$bw} 0 0 0 $bc,
				inset 0 -#{$bw} 0 0 $bc;
		}
	}
	
	.asymmetry--r {
		border-radius: 1.5rem 0 0 1.5rem;

		&::before {
			border-radius: $r 0 0 $r;
			right: calc(#{$tm + $tp} * -1);
			box-shadow: 
				inset 0 #{$bw} 0 0 $bc,
				inset #{$bw} 0 0 0 $bc,
				inset 0 -#{$bw} 0 0 $bc;
		}
	}
	
}



///////////////
// shadow

.shadow {
	$c: rgba(darkcyan, .25);
	$x: 1.5rem;
	$y: 1rem;
	
	margin: 2rem 0;
	padding: 2rem 0;
	
	.column {
		color: white;
		background: black;
		box-shadow: $x $y 0 0 $c;
	}

	[class*='asymmetry'] {
		box-shadow: none;
		position: relative;
	}
	[class*='asymmetry'] > * {
		position: relative;
		z-index: 2;
	}
	[class*='asymmetry']::before,
	[class*='asymmetry']::after {
		content: '';
		position: absolute;
		z-index: 1;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		pointer-events: none;
	}
	[class*='asymmetry']::before {
		background: $c;
	}
	[class*='asymmetry']::after {
		background: black;
	}

	.asymmetry--l {
		background: none;
		
		&::before {
			left: calc(#{$tm + $tp} * -1);
			right: -1 * $x;
			transform: translate3d(0, $y ,0);
		}
		&::after {
			left: calc(#{$tm + $tp} * -1);
		}
	}
	.asymmetry--r {
		background: none;
		
		&::before {
			left: $x;
			right: calc(#{$tm + $tp} * -1);
			transform: translate3d(0, $y ,0);
		}
		&::after {
			right: calc(#{$tm + $tp} * -1);
		}
	}
}




//////////////////////////////

///////////////
// explantion
.explanation {
	position: relative;
	margin: 2rem 0;
	padding: 0 0 2rem;
	
	background: white;
	max-width: 100vw;
	overflow: hidden;
	
	table {
		width: calc(100% - 4rem);
		margin: 1rem 2rem 0;
		
		th,
		td {
			width: 50%;
			padding: .25rem;
		}
		
		th {
			text-align: right;
			padding-right: .5rem;
		}
		td {
			text-align: left;
			padding-left: .5rem;
		}
		
		tr:nth-child(1) th {
			color: #0288D1;
		}
		tr:nth-child(2) th {
			color: #E64A19;
		}
		tr:nth-child(3) th {
			color: #2E7D32;
		}
	}
	
	input {
		border: none;
		font-size: 1rem;
		border-bottom: 1px solid lightgray;
		padding: 0 .5rem;
		width: 100%;
		
		&:focus {
			outline: none;
			border-bottom: 1px solid black;
		}
	}
	
	.container {
		position: relative;
		padding: 2rem 0;
	}
	
	[class^='txt-'] {
		position: absolute;
		z-index: 2;
		height: 1rem;
		
		border-left: 1px solid black;
		border-right: 1px solid black;
		
		text-align: center;
		
		font-size: .75rem;
		line-height: 1rem;
		
		background: repeating-linear-gradient(90deg,  black, black 50%, transparent 50%, transparent 100%) repeat-x left top 50%;
		background-size: 4px 1px;
		
		&::before {
			// content: attr(data-text);
			display: inline-block;
			margin: 0 auto;
			padding: 0 .25em;
			font-size: .75rem;
			line-height: 1rem;
		}
	}
	
	// NORMAL
	.txt-column {
		top: 3rem;
		left: 0;
		right: 0;
		margin: 0 auto;
		
		text-shadow:
			2px 0 0 #B3E5FC,
			-2px 0 0 #B3E5FC,
			2px 2px 0 #B3E5FC,
			-2px 2px 0 #B3E5FC,
			2px -2px 0 #B3E5FC,
			-2px -2px 0 #B3E5FC;
	}
	.txt-ml,
	.txt-mr{
		top: 2rem;
		border: none;
		background: none;
		&::before {
			content: attr(data-text);
			font-size: 0.6rem;
			color: #E64A19;
		}
	}
	.txt-ml {
		left: 0;
	}
	.txt-mr {
		right: 0;
	}
	.txt-maxcolumn {
		top: 5rem;
		left: -50vw;
		right: -50vw;
		margin: 0 auto;
		
		width: 700px;
		text-shadow:
			2px 0 0 #B3E5FC,
			-2px 0 0 #B3E5FC,
			2px 2px 0 #B3E5FC,
			-2px 2px 0 #B3E5FC,
			2px -2px 0 #B3E5FC,
			-2px -2px 0 #B3E5FC;
	}
	.txt-50par {
		bottom: 2rem;
		right: 0;
		
		width: 50%;
		text-shadow:
			2px 0 0 #C5E1A5,
			-2px 0 0 #C5E1A5,
			2px 2px 0 #C5E1A5,
			-2px 2px 0 #C5E1A5,
			2px -2px 0 #C5E1A5,
			-2px -2px 0 #C5E1A5;
	}
	.txt-columnhalf {
		bottom: 1rem;
		left: 50%;
		text-shadow:
			2px 0 0 white,
			-2px 0 0 white,
			2px 2px 0 white,
			-2px 2px 0 white,
			2px -2px 0 white,
			-2px -2px 0 white;
	}
	.txt-remainder {
		bottom: 1rem;
		right: 0;
		margin: 0 auto;
		border-left: none;
		border-right-color: red;
		
		background: repeating-linear-gradient(90deg,  red, red 50%, transparent 50%, transparent 100%) repeat-x left top 50%;
		background-size: 4px 1px;
		&::before {
			position: absolute;
			top: 1rem;
			right: 0;
			text-align: right;
			padding: 0 .5rem;
			content: attr(data-text);
			color: red;
			font-weight: bold;
			width: 100vw;
		}
	}

	/// ASYMMETRY
	.txt-width {
		top: 3rem;
		left: 0;
		margin: 0 auto;
		text-shadow:
			2px 0 0 #B3E5FC,
			-2px 0 0 #B3E5FC,
			2px 2px 0 #B3E5FC,
			-2px 2px 0 #B3E5FC,
			2px -2px 0 #B3E5FC,
			-2px -2px 0 #B3E5FC;
	}
	.txt-maxwidth {
		top: 5rem;
		left: 0;
		margin: 0 auto;
		max-width: 100vw;
		text-shadow:
			2px 0 0 #B3E5FC,
			-2px 0 0 #B3E5FC,
			2px 2px 0 #B3E5FC,
			-2px 2px 0 #B3E5FC,
			2px -2px 0 #B3E5FC,
			-2px -2px 0 #B3E5FC;
		
		strong {
			font-weight: bold;
			color: red;
		}
	}
	.txt-border {
		bottom: 1rem;
		left: 0;
		
		border: none;
		background: none;
		
		&::before {
			position: absolute;
			bottom: 100%;
			left: 0;
			content: attr(data-text);
			white-space: nowrap;
			background: none;
			color: #FF8F00;
			font-weight: bold;
		}
	}
	.txt-padding {
		bottom: 1rem;
		
		border-color: #7CB342;
		background: repeating-linear-gradient(90deg,  #7CB342, #7CB342 50%, transparent 50%, transparent 100%) repeat-x left top 50%;
		background-size: 4px 1px;
		
		&::before {
			content: attr(data-text);
			position: absolute;
			top: 100%;
			left: 0;
			color: #2E7D32;
			width: 10vw;
			white-space: nowrap;
			background: none;
			text-align: left;
			padding: 0 .5rem;
			font-weight: bold;
		}
	}
	
	// @media print, screen and (min-width: calc(764px)) {		
	// 	.txt-column,
	// 	.txt-ml,
	// 	.txt-mr,
	// 	.txt-width {
	// 		opacity: .5;
	// 	}
	// }
	// @media print, screen and (max-width: calc(764px)) {		
	// 	.txt-maxcolumn,
	// 	.txt-columnhalf,
	// 	.txt-remainder,
	// 	.txt-maxwidth,
	// 	.txt-padding {
	// 		opacity: .5;
	// 	}
	// }
	
	// sample
	.sample {
		position: relative;
		opacity: 1;
		background: #C5E1A5;
		
		border-color: #FFE082;
		
		> :not(.mask) {
			position: relative;
			z-index: 2;
			opacity: .1;
		}
		
		.mask {
			position: absolute;
			z-index: 1;
			background: #B3E5FC;
			pointer-events: none;
			opacity: 1;
		}
	}
	
	.sample {
		position: relative;
		opacity: 1;
		background: #C5E1A5;
	}
}



///////////////
// dummy
body {
	background: repeating-linear-gradient(-45deg, transparent, transparent 10%, #fff 10%, #fff 50%, transparent 50%, transparent 60%, #fff 60%, #fff 100%);
	background-size: 10px 10px;
	background-color: rgba(black, .5);
}
h1 {
	margin: 1em 0 0;
	font-size: 3rem;
	font-weight: 100;
	text-transform: uppercase;
	
	.L {
		display: block;
		@include asymmetry-column(l, $w:8em, $m: 0, $p: 1em);
		background-color: white;
		// padding-top: .25em;
		// padding-bottom: 0;
	}
	.C {
		display: block;
		@include asymmetry-column(c, $w:8em, $m: 0, $p: 1em);
		background-color: white;
	}
	.R {
		display: block;
		@include asymmetry-column(r, $w:8em, $m: 0, $p: 1em);
		background-color: white;
		// padding-top: 0;
		// padding-bottom: .25em;
	}
	.L, .C, .R {
		padding-top: .5rem;
		padding-bottom: .5rem;
		margin-top: .5rem;
		margin-bottom: .5rem;
	}
}
h2 {
	font-size: 2rem;
	margin-bottom: 1rem;
}

p {
	font-size: 1rem;
	line-height: 1.8;
}
              
            
!

JS

              
                
///////////////
// for Internet Explorer 11
// var init = function() {

  // instantiation disableNegativePadding
	var asymmetrys = [].slice.call(document.querySelectorAll('[class*=asymmetry]'));
	asymmetrys.forEach(function(o) {
	var myDNP = new disableNegativePadding(o);
	});

// };
// window.addEventListener('DOMContentLoaded', init, {once: true});
///////////////


///////////////
// Simulation
var explanation = new Vue({
	el: '#app-explanation',
	data: {
		w: '400px',
		m: '2rem',
		p: '1rem'
	},
	computed: {
		half() {
			var val = this.w.replace(/[^0-9]/g, '');
			var unit = this.w.replace(/[0-9]/g, '');
			return (val / 2) + unit;
		},
		columnW() {
			return 'calc(100% - ' + this.m + ' - ' + this.m + ')';
		},
		remainder() {
			return 'calc(50% - ' + this.half + ')';
		},
		width() {
			return 'calc(100% - ' +this. m +')';
		},
		maxWidth() {
			return 'calc(100% - (50% - ' + this.half + '))';
		},
		border() {
			return 'calc(' + this.m + ' + ' + this.p + ')';
		},
		padding() {
			return 'calc(50% - ' + this.half + ' - ' + this.m + ')';
		},
		styleset() {
			return {
				maxWidth: this.maxWidth,
				width: this.width,
				padding: this.p + ' ' + this.p + ' ' + this.p + ' ' + this.padding,
				marginLeft: '0',
				marginRight: 'auto',
				borderLeftStyle: 'solid',
				borderLeftWidth: this.border,
			};
		},
		outsideMargen() {
			return {
				'box-shadow': this.m + ' 0 0 0 #FFCCBC inset, -' + this.m + ' 0 0 0 #FFCCBC inset',
			};
		}
	}
});
///////////////
              
            
!
999px

Console