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 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

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

              
                .bb-8
              
            
!

CSS

              
                // OyBjxb
$orange: #e58126;
$white: #dce1e1; // #c7cdcf #d6d0c2
$brown: #8e7c61;
$silver: #97a4ac;
$gray: #2e3236;
$black: black;
$red: #ed1c24;
$sand: #ecca9a;
$sand-dark: #ad8d74;
$sky: #9fc5ce;

$d: 350px;
$r: $d / 2;
$dome-w: $d * .6;
$dome-h: $d * .4;
$dome-off: $dome-h * .1;
$antenna-w: $d * .01;
$antenna-h: $r / 2;

.bb-8 {
  // Body
  width: $d;
  height: $d;
  margin: $r * 1.5 auto $r * .25;
  border-radius: 50%;
  position: relative;

  $ring: radial-gradient(circle closest-side,
    transparent 40%, rgba($brown, .5) 45%,
    $orange 45%, $orange 60%,
    rgba($brown, .5) 60%, transparent 65%);
  $line-mask: radial-gradient(circle closest-side,
    $white 45%,
    transparent 45%);
  $line-stops:
    transparent 49.25%,
    rgba($brown, .25) 49.25%, rgba($brown, .25) 50.25%,
    transparent 50.25%;
  background:
    linear-gradient($white, $white $dome-off, rgba($gray, .2) $dome-off, transparent 10%), // Dome shadow
    radial-gradient(circle closest-side at $r * .75 $r * .75, white, rgba(white, .5) 25%, transparent), // Light glare
    radial-gradient(circle farthest-side at $r $r / 2, transparent 50%, rgba($brown, .5)), // Dirt on bottom
    $ring, $ring $r $r, // Rings
    $line-mask, $line-mask $r $r, // Line masks
    linear-gradient(45deg, $line-stops), linear-gradient(-45deg, $line-stops); // Lines;
  background-color: $white;

  $off: -$r + $dome-off;
  box-shadow:
    // Circle
    0 $dome-h * -.275 + $off 0 $dome-h * .02 - $r $white,
    0 $dome-h * -.275 + $off 0 $dome-h * .03 - $r $gray,
    0 $dome-h * -.275 + $off 0 $dome-h * .04 - $r $white,
    0 $dome-h * -.275 + $off 0 $dome-h * .05 - $r $gray,
    // Eye
    $dome-h * -.03 $dome-h * -.58 + $off 0 $dome-h * .03 - $r rgba($red, .2),
    $dome-h * -.03 $dome-h * -.58 + $off 0 $dome-h * .06 - $r rgba($red, .1),
    0 $dome-h * -.55 + $off 0 $dome-h * .1 - $r rgba($red, .1),
    0 $dome-h * -.55 + $off 0 $dome-h * .15 - $r $black,
    0 $dome-h * -.55 + $off 0 $dome-h * .20 - $r $gray,
    0 $dome-h * -.55 + $off 0 $dome-h * .25 - $r $white,
    // Holo Projector
    $dome-w * .25 $dome-h * -.35 + $off 0 $dome-h * .04 - $r $black,
    $dome-w * .25 $dome-h * -.35 + $off 0 $dome-h * .06 - $r $gray,
    $dome-w * .25 $dome-h * -.35 + $off 0 $dome-h * .08 - $r $white,
    $dome-w * .25 $dome-h * -.35 + $off 0 $dome-h * .10 - $r $gray,
    $dome-w * .25 $dome-h * -.35 + $off 0 $dome-h * .13 - $r $white;

  // Dome
  &::before {
    content: "";
    width: $dome-w;
    height: $dome-h;
    top: -$dome-h + $dome-off;
    left: ($d - $dome-w) / 2;
    border-radius: $dome-h $dome-h $dome-w / 6 $dome-w / 6;
    display: block;
    position: absolute;
    z-index: -1;

    background-image:
      linear-gradient( // Vertical stripes
        $white 10%,
        $silver 10%, $silver 20%,
        $white 20%, $white 25%,
        $orange 25%, $orange 30%,
        $white 30%, $white 70%,
        transparent 70%, transparent 80%, // This reveals the orange stripes
        $silver 80%, $silver 90%,
        $white 90%),
      linear-gradient(90deg, // Horizontal orange stripes
        $orange 5%,
        transparent 5%, transparent 7%,
        $orange 7%, $orange 10%,
        transparent 10%, transparent 12%,
        $orange 12%, $orange 27%,
        transparent 27%, transparent 31%,
        $orange 31%, $orange 35%,
        transparent 35%, transparent 80%,
        $orange 80%, $orange 83%,
        transparent 83%, transparent 85%,
        $orange 85%, $orange 95%,
        transparent 95%, transparent 97%,
        $orange 97%);
    background-color: $white;
  }

  // Antennas
  &::after {
    content: "";
    width: $antenna-w;
    height: $antenna-h;
    top: $dome-off - $dome-h - $antenna-h;
    left: $r * 1.05;
    display: block;
    position: absolute;
    z-index: -2;

    background: $gray linear-gradient( // Striped antenna
      $black 10%,
      $white 10%, $white 90%,
      $black 90%);
    box-shadow: $d * -.05 $r * .15 $white; // White antenna
  }
}

body {
  $pos: $antenna-h + $dome-h + $dome-off + $r;
  background: $sand-dark linear-gradient($sky $pos, $sand $pos, $sand-dark) repeat-x; // Sand

  &::after {
    content: "BB-8";
    padding: .5em 1em;
    left: 0;
    top: 0;
    color: $gray;
    font-family: sans-serif;
    font-size: 24px;
    position: absolute;
    z-index: -999;
  }
}

              
            
!

JS

              
                // Reference:
// http://starwars.wikia.com/wiki/BB-8

/*
@function rectangle-gradient($degrees) {
  @return linear-gradient($degrees,
    transparent 47.5%,
    $orange 47.5%, $orange 52.5%,
    transparent 52.5%);
}

@function rectangle-cover-gradient($degrees) {
  @return linear-gradient($degrees,
    $white 27.5%,
    transparent 27.5%, transparent 35%,
    $white 35%, $white 47.5%,
    transparent 47.5%, transparent 52.5%,
    $white 52.5%, $white 65%,
    transparent 65%, transparent 72.5%,
    $white 72.5%);
  // @return linear-gradient($degrees, transparent 27.5%, red 27.5%, red 35%, transparent 35%, transparent 65%, red 65%, red 72.5%, transparent 72.5%);
}
@function circle-gradient() {
  @return radial-gradient(circle $dome-h at 50% 100% - 27.5%,
    $white 2%,
    $gray 2%, $gray 3%,
    $white 3%, $white 4%,
    $gray 4%, $gray 5%,
    transparent 5%);
}
*/
              
            
!
999px

Console