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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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

              
                <div class="container">
  <h3>Pie Chart</h3>
  
  <div class="form-control piechart">
    <div class="pie-container">
      <div class="progress-pie" data-value="60">
        <div class="pie"></div>
      </div>
    </div>
  </div>
</div>
              
            
!

CSS

              
                html, body
  height: 100%
  padding: 0
  margin: 0
body
  font-family: Arial, sans-serif
  background-color: #fafafa
  display: flex
  flex-direction: column
  flex-wrap: wrap
  align-items: center
  justify-content: center
  text-align: center

//------------------------//
// PIE CHART (form comp.) //
//------------------------//
$base-color: #e6e6e6
$active-color: #ff5151

.form-control
  margin-top: 20px
  &:first-child
    margin-top: 0

  // PIECHART
  &.piechart
    $pieR: 150px
    $pieW: 20px

    .pie-container
      position: relative
      width: $pieR

      &:before
        content: ''
        display: block
        position: absolute
        top: calc(50% - 0.25em)
        left: 0
        width: 100%
        text-align: center
        line-height: 1em

      .progress-pie
        position: relative
        width: $pieR
        height: $pieR
        box-sizing: border-box
        border-radius: 50%
        border-top: $pieW solid $active-color
        border-right: $pieW solid $active-color
        border-bottom: $pieW solid $base-color
        border-left: $pieW solid $base-color
        transform: rotate(45deg)
        
        &:after
          content: ''
          display: block
          position: absolute
          z-index: 5
          top: 0
          left: 0
          width: $pieR - $pieW*2
          height: $pieR - $pieW*2
          border-radius: 50%
          transform: rotate(-45deg)
          box-shadow: 0 0 6px rgba(0,0,0,0.15)

        .pie
          display: block
          width: $pieR
          height: $pieR
          box-sizing: border-box
          border-radius: 50%
          margin: (-$pieW) 0 0 (-$pieW)
          border-bottom: $pieW solid transparent
          border-left: $pieW solid transparent
          border-top: $pieW solid $base-color
          border-right: $pieW solid $base-color
          transform-origin: 50% 50%
          transform: rotate(0deg)

          &.mt50
            border-bottom: $pieW solid $active-color
            border-left: $pieW solid $active-color
            border-top: $pieW solid transparent
            border-right: $pieW solid transparent
              
            
!

JS

              
                $(document).ready(function() {
  
  $('.piechart').each(function() {
    var val = $(this).find('.progress-pie').data('value');   
       
    if( val > 50 ) {
      $(this).find('.pie').addClass('mt50');
    }
    $(this).find('.progress-pie')
      .prepend("<style>.pie-container:before{content:'" + val + " %' !important}</style>")
      .children('.pie').css('transform', 'rotate(' + val * 3.6 + 'deg)');
  });
  
});
              
            
!
999px

Console