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

              
                <header>
  <h1>#1 - Dicey Loader With Flexbox</h1>
</header>

<!-- 
  Our Dice's Faces
-->
<div class="dice">
  
  <div class="face first-face">
    <div class="dot"></div>  
  </div>
  
  <div class="face second-face">
    <div class="dot"></div>  
    <div class="dot"></div>  
  </div>
  
  <div class="face third-face">
    <div class="dot"></div>  
    <div class="dot"></div>
    <div class="dot"></div>
  </div>
  
  <div class="face fourth-face">
    <div class="column">
      <div class="dot"></div>  
      <div class="dot"></div>  
    </div>
    <div class="column">
      <div class="dot"></div>  
      <div class="dot"></div>  
    </div>    
  </div>
  
  <div class="face fifth-face">
    <div class="column">
      <div class="dot"></div>  
      <div class="dot"></div>  
    </div>
    <div class="column">
      <div class="dot"></div>
    </div>
    <div class="column">
      <div class="dot"></div>  
      <div class="dot"></div>  
    </div>    
  </div>
  
  <div class="face sixth-face">
    <div class="column">
      <div class="dot"></div>  
      <div class="dot"></div>
      <div class="dot"></div>
    </div>
    <div class="column">
      <div class="dot"></div>  
      <div class="dot"></div>  
      <div class="dot"></div>
    </div>    
  </div>
  
</div>


<p>Wait, please...</p>
              
            
!

CSS

              
                // DEMO SET-UP
$col-1: #F44336
$col-2: #E91E63
$col-3: #9C27B0
$col-4: #673AB7
$col-5: #3F51B5
$col-6: #2196F3

body
  font-family: 'Crafty Girls', cursive
  font-size: 16px 
h1
  padding: 3rem 1rem 0
  text-align: center
  line-height: 1.3
  letter-spacing: 4px
  font-size: 2em
p
  padding: 3rem 1rem 0
  text-align: center
  line-height: 1.3
  letter-spacing: 4px
  font-size: 1.125em

  
  
  

/******************************
 FLEXBOX STYLES
 ******************************/

// CENTERING OUR FACES
.dice
  display: flex
  margin-top: 4rem
  justify-content: center
 

// OUR DICE FACES
.face
  display: flex
  width: 3rem
  height: 3rem
  margin: 0 .7rem
  padding: .5rem
  border-radius: 5px
  opacity: 0
  .dot
    width: .8rem
    height: .8rem
    background: $col-1
    border-radius: 50% 
  &:nth-child(1)
    border: 2px solid $col-1
    animation: waves 5s linear infinite
    .dot
      background: $col-1
  &:nth-child(2)
    border: 2px solid $col-2
    animation: waves 5s .2s linear infinite
    .dot
      background: $col-2
  &:nth-child(3)
    border: 2px solid $col-3
    animation: waves 5s .4s linear infinite
    .dot
      background: $col-3
  &:nth-child(4)
    border: 2px solid $col-4
    animation: waves 5s .6s linear infinite
    .dot
      background: $col-4
  &:nth-child(5)
    border: 2px solid $col-5
    animation: waves 5s .8s linear infinite
    .dot
      background: $col-5
  &:nth-child(6)
    border: 2px solid $col-6
    animation: waves 5s 1s linear infinite
    .dot
      background: $col-6
// Vertical centering  
.first-face
  justify-content: center
  align-items: center

// Individual positioning (align-self)
.second-face
  justify-content: space-between
  .dot:last-of-type
    align-self: flex-end

// More individual positioning
.third-face
  justify-content: space-between
  .dot:nth-child(2)
    align-self: center
  .dot:last-of-type
    align-self: flex-end
    
    
// Nesting flex containers with different flex-direction
.fourth-face
  justify-content: space-between
  .column
    display: flex
    flex-direction: column
    justify-content: space-between

// more nesting  
.fifth-face
  justify-content: space-between
  .column
    display: flex
    flex-direction: column
    justify-content: space-between
    &:nth-child(2)
      justify-content: center

// Again nesting
.sixth-face
  justify-content: space-between
  .column
    display: flex
    flex-direction: column
    justify-content: space-between
    
    
/*******************************************************/
    
    
// Lets animate our faces!

@keyframes waves
  0%
    transform: translateY(0)
    opacity: 0
  4%
    transform: translateY(-25px)
    opacity: 1
  8%
    transform: translateY(0)
    opacity: 1
  70%
    opacity: 0
              
            
!

JS

              
                /***

Experimenting with Flexbox

Loading screen animation 

***/
              
            
!
999px

Console