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

              
                <h1>CSS Shapes with Sass</h1>
<p>Mixins to create commonly used shapes in CSS</p>
<div class="flex-ctnr">
   <div class="ctnr">
      <div class="parallelogram"></div>
   </div>
   <div class="ctnr">
      <div class="oval"></div>
   </div>
   <div class="ctnr">
      <div class="up-triangle"></div>
   </div>
   <div class="ctnr">
      <div class="down-triangle"></div>
   </div>
   <div class="ctnr">
      <div class="left-triangle"></div>
   </div>
   <div class="ctnr">
      <div class="right-triangle"></div>
   </div>
   <div class="ctnr">
      <div class="top-left-triangle"></div>
   </div>
   <div class="ctnr">
      <div class="top-right-triangle"></div>
   </div>
   <div class="ctnr">
      <div class="bottom-left-triangle"></div>
   </div>
   <div class="ctnr">
      <div class="bottom-right-triangle"></div>
   </div>
   <div class="ctnr">
      <div class="trapezoid"></div>
   </div>
   <div class="ctnr">
      <div class="chevron"></div>
   </div>
   <div class="ctnr ctnr--hex-adjust">
      <div class="hexagon"></div>
   </div>
</div>
<hr>
<h3 class="tal">Credits:</h3>
<ul class="tal">
   <li>Similar demo in CodePen: <a href="https://codepen.io/ricardozea/pen/feiLs" target="_blank">CSS Arrows/Triangles Combinations</a></li>
   <li>Demo insipired by Ilan Biala's <a href="https://ilanbiala.github.io/CSS-Shapes/" target="_blank">CSS-shapes page</a></li>
   <li>Awesome post from <a href="http://www.sitepoint.com/author/hgiraudel/" target="_blank">Hugo Giraudel</a> about <a href="http://www.sitepoint.com/sass-mixin-css-triangles/" target="_blank">A Sass Mixin for CSS Triangles</a></li>
   <li><a href="https://codepen.io/Garrett-/pen/wgczf" target="_blank">Stylus fork</a> by <a href="https://codepen.io/Garrett-/" target="_blank">@Garret</a></li>
   <li>The hexagon suggested by <a href="https://codepen.io/agilepixel/" target="_blank">Henry (agilepixel)</a> from <a href="https://codepen.io/agilepixel/pen/FEJkG" target="_blank">this pen</a> he created</li>
</ul>
<hr>
<p>Created by <a href="http://ricardozea.me/" target="_blank">Ricardo Zea</a></p>
<time datetime="4-22-2014">On: May 19, 2014</time>
              
            
!

CSS

              
                
//Colors - Not needed for demo
$r: #c03;
$g: #429032;
$b: #2963BD;
$y: #c90;

//Shapes demo starts
@mixin rectangle($width, $height, $color) {
	width: $width;
	height: $height;
	background: $color;
}

@mixin parallelogram($width, $height, $skew, $color) {
	@include rectangle($width, $height, $color);
	background: $color;
	transform: skew($skew);
}

@mixin square($size, $color) {
	@include rectangle($size, $size, $color);
}

@mixin circle($size, $color) {
	@include square($size, $color);
	border-radius: $size / 2;
}

@mixin oval($width, $height, $color) {
	width: $width;
	height: $height;
	border-radius: #{$width} / #{$height};
	background: $color;
}

@mixin triangle($direction, $size, $color) {
	width: 0;
	height: 0;

	@if $direction == 'up' { 
		border-right: $size solid transparent;
		border-bottom: $size * 1.732 solid $color; 
		border-left: $size solid transparent; 
	} @else if $direction == 'down' {
		border-top: $size * 1.732 solid $color; 
		border-right: $size solid transparent; 
		border-left: $size solid transparent; 
	} @else if $direction == 'left' {
		border-top: $size solid transparent; 
		border-right: $size * 1.732 solid $color; 
		border-bottom: $size solid transparent; 
	} @else if $direction == 'right' {
		border-top: $size solid transparent; 
		border-bottom: $size solid transparent; 
		border-left: $size * 1.732 solid $color; 
	}
}

@mixin corner-triangle($corner, $size, $color) {
	width: 0;
	height: 0;

	@if $corner == 'top-left' { 
		border-top: $size solid $color;
		border-right: $size solid transparent;
	} @else if $corner == 'top-right' {
		border-top: $size solid $color;
		border-left: $size solid transparent; 
	} @else if $corner == 'bottom-left' {
		border-right: $size solid transparent;
		border-bottom: $size solid $color;
	} @else if $corner == 'bottom-right' {
		border-bottom: $size solid $color;
		border-left: $size solid transparent;
	}
}

@mixin trapezoid($width, $color) {
	width: $width;
	height: 0;
	border-right: $width / 2 solid transparent;
	border-bottom: $width solid $color;
	border-left: $width / 2 solid transparent;
	box-sizing: content-box; //If you have 'box-sizing:border-box' the trapezoid doesn't work.
}

@mixin chevron($direction, $width, $height, $skew, $color) {
	position: relative;
	width: $width;
	height: $height;
	&:before, &:after {
		position: absolute;
		top: 0;
		width: 50%;
		height: 100%;
		background: $color;
		content: '';
	}
	&:before {
		left: 0;
		transform: skew(0deg, $skew);
	}
	&:after {
		right: 0;
		transform: skew(0deg, -$skew);
	}
}

@mixin hexagon($width, $height, $color){
  height: $height;
  padding: 0 $width;
  background: $color;
  font-size: $height / 2;
  display: inline-block;
  position: relative;
  line-height: 1.8;     
  
  &:before, &:after {
    position: absolute;
    content: "";
    height: 0;
    width: 0;
    top: 0;
    border-top: $height / 2 solid transparent;
    border-bottom: $height / 2  solid transparent;
    transform:rotateY(180deg);
  }
  &:before {
    left: 100%;
    border-right: $height / 2 solid $color;
  }
  &:after {
    right: 100%;
    border-left: $height / 2 solid $color;    
  }
}

//Usage:
.parallelogram {
	@include parallelogram(100px, 70px, 10deg, $r );
}
.oval {
	@include oval(100px, 50px, $g);
}
.up-triangle {
	@include triangle(up, 60px, $b );
}
.down-triangle {
	@include triangle(down, 60px, $y );
}
.left-triangle {
	@include triangle(left, 60px, $r );
}
.right-triangle {
	@include triangle(right, 60px, $g );
}
.top-left-triangle {
	@include corner-triangle(top-left, 120px, $b );
}
.top-right-triangle {
	@include corner-triangle(top-right, 120px, $y );
}
.bottom-left-triangle {
	@include corner-triangle(bottom-left, 120px, $r );
}
.bottom-right-triangle {
	@include corner-triangle(bottom-right, 120px, $g );
}
.trapezoid {
	@include trapezoid(80px, $b );
}
.chevron {
	@include chevron(down, 120px, 40px, 15deg, $y );
}
.hexagon {
  @include hexagon(30px, 62px, $r);
}

.info { display: inline-block; margin-bottom: 10px; background: none; box-shadow: none; color: rgba(white,.7); white-space: nowrap; background: rgba(black,.3); }

//Styling stuff not needed for demo
.ctnr { padding: 10px 20px 20px; margin: 10px; background: rgba(black,.2); border-radius: 2px; box-shadow: inset 0 0 0 2px rgba(black,.05), 1px 1px 5px rgba(black,.2); position: relative;
   &--hex-adjust { @extend .ctnr; padding: 45px 50px 20px; }
   div { margin: auto; }   
}
.ctnr--hex-adjust .info { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); }
.flex-ctnr { display:flex; flex-wrap:wrap; align-items:center;  }
.tal { text-align: left; }
              
            
!

JS

              
                /*None of these scripts are needed for the demo*/

//Add a title to the links that open in a new tab/window
$("a[target='_blank']").attr({title:"Opens in a new tab/window"}).addClass("new-window");

//Prepend a <code> tag with the class .info
$(".ctnr").each(function() {
  var code = $("<code>").addClass("info").text("." + $(this).find("div").attr("class"));
  code.prependTo(this);
});


              
            
!
999px

Console