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>CSS Polygons</h1>
<p class="by">by <a href="https://twitter.com/geoffreycrofte">@geoffreycrofte</a></p>

<p>Those polygons are realized with the rotate CSS3 property and a hidden overflow. You can click on the button "debug mode" below to reveal boxes. If you have other ways to realize advanced shapes, use the comment form ;)</p>


<div class="part">
  <h2>Losange</h2>
    <div class="losange">
      <div class="los1">
        <img src="http://farm3.staticflickr.com/2178/3531465579_8bff044e9b_z.jpg?zz=1" alt="" width="255" height="320" />
      </div>
    </div>
</div>

<div class="part">
  <h2>Diamond</h2>
    <div class="diamond">
      <div class="dia">
        <img src="http://farm3.staticflickr.com/2441/3657346647_a11111ed39_z.jpg?zz=1" alt="" width="320" height="316" />
      </div>
    </div>
</div>


<div class="part">
  <h2>Hexagon</h2>
    <div class="hexa">
      <div class="hex1">
        <div class="hex2">
          <img src="http://farm3.staticflickr.com/2788/4392569951_8bcec3b3ed_z.jpg?zz=1" alt="" width="320" height="313" />
        </div>
      </div>
    </div>
</div>

<div class="part">
  <h2>Octogon</h2>
    <div class="octo">
      <div class="octo1">
        <img src="http://farm3.staticflickr.com/2441/3657346647_a11111ed39_z.jpg?zz=1" alt="" width="320" height="316" />
      </div>
    </div>
</div>


<div class="part">
  <h2>Dodecagon</h2>
    <div class="dodeca">
      <div class="dode1">
        <div class="dode2">
          <img src="http://farm4.staticflickr.com/3637/3658139504_c33433f163_z.jpg?zz=1" alt="" width="320" height="313" />
        </div>
      </div>
    </div>
</div>

<div class="part">
  <h2>Irregular Dodecagon</h2>
    <div class="dodeca irr">
      <div class="dode1">
        <div class="dode2">
          <img src="http://farm4.staticflickr.com/3403/3657053401_3e106f8b51_z.jpg?zz=1" alt="" width="320" height="317" />
        </div>
      </div>
    </div>
</div>

<button type="button" class="dev">debug mode</button>

<p class="photos">Photographies by <a href="http://www.flickr.com/photos/vonschnauzer">Vincent</a></p>
              
            
!

CSS

              
                /*
 * ==== Losange
 */
.losange, .losange div {
  margin: 0 auto;
  transform-origin: 50% 50%;
  overflow: hidden;
  width: 250px;
  height: 250px;
}
.losange {
  transform: rotate(45deg) translateY(10px);
}
.losange .los1 {
  width: 355px;
  height: 355px;
  transform: rotate(-45deg) translateY(-74px);
}
.losange .los1 img {
  width: 100%;
  height: auto;
}



/*
 * ==== diamond 
 */

.diamond, .dia {
  margin: 0 auto;
  transform-origin: 50% 50%;
  overflow: hidden;
  width: 300px;
  height: 300px;
}
.diamond {
  transform: rotate(45deg) translateY(-25px) translateX(-25px);
}
.diamond .dia {
  width: 380px;
  height: 380px;
  transform: rotate(-45deg);
}
.diamond img {
  width: 100%;
  height: auto;
}


/* 
 * ==== octogone
 */
.octo, .octo div {
  margin: 0 auto;
  transform-origin: 50% 50%;
  overflow: hidden;
  width: 300px;
  height: 300px;
}
.octo, .octo div {
  width: 270px;
  height: 270px;
}
.octo {
  transform: rotate(45deg);
}
.octo1 {
  transform: rotate(-45deg);
}



/*
 * ==== hexagon
 */
.hexa, .hexa div {
  margin: 0 auto;
  transform-origin: 50% 50%;
  overflow: hidden;
  width: 300px;
  height: 300px;
}
.hexa {
  width: 325px;
  height: 230px;
}
.hexa div {
  width: 100%;
  height: 100%;
}
.hexa {
  transform: rotate(120deg);
}
.hex1 {
  transform: rotate(-60deg);
}
.hex2 {
  transform: rotate(-60deg);
}

/*
 * ==== dodecagon
 */
.dodeca, .dodeca div {
  margin: 0 auto;
  transform-origin: 50% 50%;
  overflow: hidden;
  width: 300px;
  height: 300px;
}
.dodeca {
  transform: rotate(120deg);
}
.dode1 {
  transform: rotate(-60deg);
}
.dode2 {
  transform: rotate(-60deg);
}

/* irregular dodecagon */
.irr, .irr div {
  width: 320px;
}















/* dev mode */
.part.devmode div {
  box-shadow: 0 0 4px;
}
/* presentation */
body {
  padding: 0; margin: 0;
  font-family: "Open Sans Condensed", "Open Sans", "Droid Sans", sans-serif;
  font-size: 1.2em;
  line-height: 1.7;
  background: #208C8C;
  color: #DFF7E5;
}
h1, h2 {
  font-weight: normal;
  text-align: center;
}
h1 {
  margin-bottom: 0;
}
h2 {
  margin: 0 0 1.7em;
}
p {
  max-width: 600px;
  margin: 3em auto;
  text-align: center;
}
a {
  color: #FFF;
}
.by {
  margin-top: 0;
  opacity: .5;
  transition: opacity .4s;
}
.by:hover,
.by a:focus {
  opacity: 1;
}
.by, .photos {
  font-size: .8em;
}
.part {
  padding: 50px 20px 85px;
  background: #205B73;
  color: #AFE4FC;
}
.part:nth-of-type(2n) {
  background: #F2E6A7;
  color: #CDAE51
}
.dev {
  display: block;
  margin: 1.5em auto;
  max-width: 200px;
  padding: 15px 25px;
  border: 2px solid #FFF;
  background: transparent;
  color: #FFF;
  font-size: .9em;
  font-weight: bold;
  cursor: pointer;
  transition: all .4s
}
.dev:hover,
.dev:focus {
  background: rgba(0,0,0,.2);
}
.hexa img {
  position: relative;
  top: -25px;
  left: 20px;
}
.octo div img {
  position :relative;
  left:-5px; top: -5px;
}
.diamond img {
  position: relative;
  width: 105%; left: -7px; top: -5px;
}
              
            
!

JS

              
                /* just to see boxes in "dev mode" */
$('.dev').on('click', function(){
  $('.part').toggleClass('devmode');
  return false;
});
              
            
!
999px

Console