123

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              .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

            
          
!
            
              @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);
      }
    }
  }
}


            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console