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

              
                <div class="avatar-container">
  <div id="avatar" class="avatar"></div>
</div> 
              
            
!

CSS

              
                $avatar-size: 9rem

.avatar-container
  background-color: #bf9de0
  margin-left: -1 * $avatar-size / 2
  margin-top: -1 * $avatar-size / 2
  width: $avatar-size
  height: $avatar-size
  border-radius: 50%
  border: $avatar-size/15 solid #7c5cd1
  position: absolute
  top: 50%
  left: 50%
.avatar
  cursor: pointer
  color: red
  width: $avatar-size
  height: $avatar-size
  border-radius: 50%
  overflow: hidden
  background: url(https://shubox.io/images/avatar.png) center center no-repeat, url(https://shubox.io/images/avatar.png) left 100% no-repeat
  background-size: $avatar-size/2, 100% 0%
  overflow: hidden
  
  img
    width: 100%
    height: 100%
    border-radius: 50%

// loop through each step in the progress percentage
// and update the position of bottom background image.
// 100 % wide, by i % high
@for $i from 1 through 100
  $percentage: 100 / 100 * $i
  .avatar[data-shubox-progress='#{$percentage}']
    background-size: $avatar-size/2, 100% ($percentage * 1%)


              
            
!

JS

              
                new Shubox("#avatar", {
  key: "7e1e4069",
  // image transform queue
  transformName: 'avatar-demo',
  // do not use built-in previewsContainer
  previewsContainer: false,
  // on success - insert the image w/a flip-in
  // animate.css classname
  success: function(file) {
    // create new image element
    let img = new Image();

    // once loaded, insert it inside div#avatar
    img.onload = function() {
      let el = document.getElementById('avatar')
      el.insertAdjacentHTML('beforeend', '<img src="' + file.s3url + '">')
    };

    // assign the src and let it load
    img.src = file.s3url;
  },
  transformCallbacks: {
    // once the 200x200 WEBP is created, and found, replace the image with this one
    "200x200#.webp": function(shuboxFile) {
       console.log(shuboxFile.transforms["200x200#.webp"].s3url)
       document.querySelector("#avatar img").src = shuboxFile.transforms["200x200#.webp"].s3url;
     }
  }
})
              
            
!
999px

Console