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

              
                h1
 | ¿Cómo se hace un triángulo con CSS?

#whole-thing
  .steps
    .step-0
      | Imagina un caja.
    .step-1
      | La caja tiene un borde superior.
    .step-2
      | También tiene otros bordes.
    .step-5
      | Detalla como los bordes se unen en ángulos en las esquinas.
    .step-6
      | El fondo de la caja es transparente.
    .step-7
      | La caja ahora tiene ancho y alto 0.
    .step-8
      | Los tres bordes ahora tienen color transparente.
    .step-11
      | ¡Así es como se crea un triángulo con CSS!
      
  .triangle-demo
  .triangle-title
    button#re-run
      | Empezar de nuevo.
  
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Andika);

$stepTiming: 0.8s 0.2s;

.triangle-demo {
  width: 100px;
  height: 100px;
  margin: 0 auto;
  background: tan;
  border-top: 0 solid #EE7C31;
  border-left: 0 solid #F5D97B; 
  border-bottom: 0 solid #D94948;
  border-right: 0 solid #8DB434;
  transition: $stepTiming;
  
  .step-1 & {
    border-top-width: 10px;
  }
  .step-2 & {
    border-left-width: 10px;
  }
  .step-3 & {
    border-right-width: 10px;
  }
  .step-4 & {
    border-bottom-width: 10px;
  }
  .step-6 & {
    background: transparent;
  }
  .step-7 & {
    width: 0; height: 0;
  }
  .step-8 & {
    border-left-color: transparent;
  }
  .step-9 & {
    border-right-color: transparent;
  }
  .step-10 & {
    border-top-color: transparent;
  }
}

.triangle-title {
  width: 300px;
  padding: 1rem;
  color: white;
  background: #D94948;
  border-radius: 20px;
  margin: auto;
  opacity: 0;
  transition: $stepTiming;
  .step-11 & {
    opacity: 1;
  }
}

body {
  background: #333;
  font-family: 'Andika', sans-serif;
  color: white;
  text-align: center;
  font-size: large;
  transform: translateZ(0);
}

.steps {
  position: relative;
  height: 45px;
  > div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    opacity: 0;
    background: #333;
    transition: 0.3s;
  }
  .step-0 {
    opacity: 1; 
  }
  .step-1 & .step-1 {
    opacity: 1; 
  }
  .step-2 & .step-2 {
    opacity: 1; 
  }
  .step-5 & .step-5 {
    opacity: 1; 
  }
  .step-6 & .step-6 {
    opacity: 1; 
  }
  .step-7 & .step-7 {
    opacity: 1; 
  }
  .step-8 & .step-8 {
    opacity: 1; 
  }
  .step-11 & .step-11 {
    opacity: 1; 
  }
}

h1 {
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 1.5rem;
  border-bottom: 1px solid #555;
  color: #999;
}
              
            
!

JS

              
                demo = $("#whole-thing")

run = () ->

  # Imagine a box
  
  # The box has border-top
  setTimeout ->
    demo.addClass("step-1")
  , 2500
  
  # It also has the other borders
  setTimeout ->
    demo.addClass("step-2")
  , 5000
  setTimeout ->
    demo.addClass("step-3")
  , 5500
  setTimeout ->
    demo.addClass("step-4")
  , 6000
  
  # Notice how the borders meet each other at angles.
  setTimeout ->
    demo.addClass("step-5")
  , 7500
  
  # The background of the box is transparent.
  setTimeout ->
    demo.addClass("step-6")
  , 10000
  
  # The box is actually zero width and zero height.
  setTimeout ->
    demo.addClass("step-7")
  , 12000
  
  # Three of the borders are actually transparent in color.
  setTimeout ->
    demo.addClass("step-8")
  , 14000
  setTimeout ->
    demo.addClass("step-9")
  , 14500
  setTimeout ->
    demo.addClass("step-10")
  , 15000
  
  ## Done
  setTimeout ->
    demo.addClass("step-11")
  , 18000
  
  
run()

$("#re-run").on 'click', ->
  $("#whole-thing").removeClass()
  run()
  
              
            
!
999px

Console