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="grain"></div>
              
            
!

CSS

              
                $black: #000000;
$rice: #D8D8D6;
$wood: #DDAD82;


*, *:before, *:after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
}

body {
  height: 100vmin;
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, $black 15%, $black 100%);
}

div:before, div:after {
  display: block;
  content: '';
  position: absolute;
}


div.grain {
    width: 100vmin;
    height: 100vmin;
    margin: 0 auto;
    position: relative;
    perspective-origin: bottom right;
    display: flex;
    justify-content: center;
    align-items: center;  
}

div.grain:before {
    width: 100vmin;
    height: 100vmin;
    z-index: 99;
    margin-top: -60vmin;
    transform: perspective(50px) rotateX(-15deg) rotateY(-40deg) rotateZ(-20deg);
    justify-content: center;
    align-items: center;  
}

div.grain:after {
    width: 100vmin;
    height: 100vmin;
    z-index: 89;
    margin-top: -20vmin;
    transform: perspective(150px) rotateX(-15deg) rotateY(-30deg) rotateZ(-22deg);
    justify-content: center;
    align-items: center;  
    background: 

      
    /* chopstick - top */ 
    linear-gradient($wood 0%, darken($wood, 30%) 30%, darken($wood, 50%) 90%, transparent 100%) 0vmin 47vmin / 300vmin 6vmin no-repeat,
  
    /* grain of rice */ 
    radial-gradient(ellipse, $rice 0vmin, darken($rice, 30%) 6.9vmin,  transparent 7vmin)  25vmin 49vmin / 15vmin 25vmin no-repeat, 
      
    /* chopstick - bottom */ 
    linear-gradient($wood 0%, darken($wood, 30%) 30%, darken($wood, 50%) 80%, transparent 100%) 0vmin 70vmin / 300vmin 6vmin no-repeat,
    ;
}
      
              
            
!

JS

              
                /*  This entry for #divtober was not at all where I thought I was going, but making a bowl of rice was proving cumbersome, and I wanted to explore perspective again with the chopsticks, so it's just a single grain of rice. There is a time-lapse video of this on Youtube at https://youtu.be/C697rCRzlFo  */
              
            
!
999px

Console