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

              
                .container
  h1.title Polygons
  ul.list
    li.lists--odd
      h2 5
      .pentagon
        - var i = 5;
        while i--
          div.rect
    li.lists
      h2 6
      .hexagon
        - var i = 3;
        while i--
          div.rect
    li.lists
      h2 8
      .octagon
        - var i = 4;
        while i--
          div.rect
    li.lists--odd
      h2 9
      .nonagon
        - var i = 9;
        while i--
          div.rect
    li.lists
      h2 10
      .decagon
        - var i = 5;
        while i--
          div.rect
    li.lists
      h2 12
      .dodecagon
        - var i = 6;
        while i--
          div.rect
    li.lists--odd
      h2 15
      .pentadecagon
        - var i = 15;
        while i--
          div.rect
    li.lists
      h2 16
      .hexadecagon
        - var i = 8;
        while i--
          div.rect
    li.lists
      h2 18
      .octadecagon
        - var i = 9;
        while i--
          div.rect
    li.lists
      h2 20
      .icosagon
        - var i = 10;
        while i--
          div.rect

              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Quattrocento+Sans);

$size: 200px;
$bk-color: #f5f5f5;
$border-color: #333;
$rect-even-color: #333;
$rect-odd-color: transparent;
$text-even-color: #fff;
$text-odd-color: #000;

@mixin center {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  margin: auto;
}

@mixin center-tf {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}

@mixin border {
  box-sizing: border-box;
  border: 1px solid $border-color;
  border-left: none;
  border-right: none;
}

body {
  width: 100%;
  height: 100%;
  background: $bk-color;
}

.container {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  margin: 0 auto;
  .title {
    position: relative;
    box-sizing: border-box;
    width: 200px;
    height: 40px;
    line-height: 40px;
    margin: 40px auto 0;
    padding-left: 10px;
    font-size: 11px;
    text-transform: uppercase;
    text-align: center;
    letter-spacing: 10px;
    font-family: 'Quattrocento Sans';
    &:before,
    &:after {
      content: '';
      position: absolute;
      top: calc(50% - 1px);
      width: 10px;
      height: 1px;
      background: #333;
    }
    &:before {
      left: 0;
    }
    &:after {
      right: 0;
    }
  }
}

.list {
  text-align: center;
}

.lists,
.lists--odd {
  position: relative;
  display: inline-block;
  width: 10%;
  min-width: $size * 1.5;
  height: $size * 1.5;
  h2 {
    font-size: 12px;
    color: $text-even-color;
    font-family: 'Quattrocento Sans';
    z-index: 1;
    @include center-tf;
  }
}

.lists--odd {
  h2 {
    color: $text-odd-color;
  }
}

.pentagon,
.hexagon,
.dodecagon,
.octagon,
.nonagon,
.decagon,
.pentadecagon,
.hexadecagon,
.octadecagon,
.icosagon {
  width: $size;
  height: $size;
  @include center;
  .rect {
    background: $rect-even-color;
    transform-origin: center center;
    @include border;
    @include center;
  }
}

.lists--odd {
  .rect {
    background: $rect-odd-color;
  }
}

.pentagon {
  .rect {
    width: 72.65425280053%;// √(5-2√5)
    height: 100%;
    border-top: none;
    @for $i from 0 through 4 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(72deg * $i);
      }
    }
  }
}

.hexagon {
  .rect {
    width: 57.735026919%;// (50/√3)*2
    height: 100%;
    @for $i from 0 through 2 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(60deg * $i);
      }
    }
  }
}

.octagon {
  .rect {
    width: 41.421356237%;// √2-1
    height: 100%;
    @for $i from 0 through 3 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(45deg * $i);
      }
    }
  }
}

.nonagon {
  .rect {
    width: 36.397023426%;// tan(π/9)
    height: 100%;
    border-top: none;
    @for $i from 0 through 8 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(40deg * $i);
      }
    }
  }
}

.decagon {
  .rect {
    width: 32.491969623%;// √(25-10√5)/5
    height: 100%;
    @for $i from 0 through 4 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(36deg * $i);
      }
    }
  }
}

.dodecagon {
  .rect {
    width: 26.794919243%;// 2-√3 円に外接する正多角形
    height: 100%;
    @for $i from 0 through 5 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(30deg * $i);
      }
    }
  }
}

.pentadecagon {
  .rect {
    width: 21.255656167%;// (-√(50-22√5)-√15+3√3)/2
    height: 100%;
    border-top: none;
    @for $i from 0 through 14 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(24deg * $i);
      }
    }
  }
}

.hexadecagon {
  .rect {
    width: 19.891236738%;// tan(π/16)
    height: 100%;
    @for $i from 0 through 7 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(22.5deg * $i);
      }
    }
  }
}

.octadecagon {
  .rect {
    width: 17.63269807%;// tan(π/18)
    height: 100%;
    @for $i from 0 through 8 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(20deg * $i);
      }
    }
  }
}

.icosagon {
  .rect {
    width: 15.838444032%;// -√(5+2√5)+√5+1
    height: 100%;
    @for $i from 0 through 9 {
      &:nth-of-type(#{$i + 1}) {
        transform: rotate(18deg * $i);
      }
    }
  }
}


              
            
!

JS

              
                
              
            
!
999px

Console