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

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

              
                html
  head
    link(href='https://fonts.googleapis.com/css?family=Ubuntu:300,400,500',rel='stylesheet',type='text/css')
    link(rel='stylesheet',href='//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css')
  body
    p Want to give you a clue ? It's a "demo"...
    .main
      .links
        #signin-form
          .backdrop
            a(href='#')
          form
            .rainbow
            .input
              .icon
                i#username-icon.fa.fa-user
                i#username-alert.fa.fa-exclamation-circle
              input(type='text',placeholder='Username',name='username',onclick="removeClass(this.parentNode,'error')")
              .tooltip Oops!
            .input
              .icon
                i#password-icon.fa.fa-key
                i#password-alert.fa.fa-exclamation-circle
              input(type='password',placeholder='Password',name='password',onclick="removeClass(this.parentNode,'error')")
              .icon.purple
                button(onclick="submitForm('#signin-form > form',this)")
                  i#signin-icon.fa.fa-sign-in
                  i#refresh-icon.fa.fa-refresh
              .tooltip That is wrong!
        a.link-signin(href='#signin-form') Sign In
        a.link-forgot(href='#') forgot?
              
            
!

CSS

              
                @import "compass/css3";

$bg: #292931;
$form-bg: #423142;
$pink-touch: #DE3370;
$link-color: #6B5A6B;
$grey: #DEDEDE;
$purple-touch: #AE6AA8;
$rainbow: gradient(linear,  left top,  right top, 
        color-stop(0%, rgb(255, 128, 128)), 
        color-stop(15%, rgb(255, 255, 128)),
        color-stop(30%, rgb(128, 255, 128)),
        color-stop(50%, rgb(128, 255, 255)),
        color-stop(65%, rgb(128, 128, 255)),
        color-stop(80%, rgb(255, 128, 255)),
        color-stop(100%, rgb(255, 128, 128)));

.rainbow {
    background-image: $rainbow;
    background-image: -webkit-+$rainbow;
    background-image: -moz-+$rainbow;
    background-image: -o-+$rainbow;
    background-size: 200%;
    background-repeat: repeat-x;
    border-top-left-radius: .25em;
    -webkit-border-top-left-radius: .25em;
    -moz-border-top-left-radius: .25em;
    border-top-right-radius: .25em;
    -webkit-border-top-right-radius: .25em;
    -moz-border-top-right-radius: .25em;
    width: 100%;
    top: 0; left: 0;
    height: 0.25em;
    position: absolute;
    transition: opacity .1s ease-in;
    opacity: 0;
    &.active {
      opacity: 1;
      animation: rainbowAnimation 1s linear infinite;
      -webkit-animation: rainbowAnimation 1s linear infinite;
      -moz-animation: rainbowAnimation 1s linear infinite;
      -o-animation: rainbowAnimation 1s linear infinite;
    }
}

@keyframes rainbowAnimation {
    0% { background-position: 200% 0% }
    100% { background-position: 0% 0% }
}

@-webkit-keyframes rainbowAnimation {
    0% { background-position: 200% 0% }
    100% { background-position: 0% 0% }
}

@-moz-keyframes rainbowAnimation {
    0% { background-position: 200% 0% }
    100% { background-position: 0% 0% }
}

@-o-keyframes rainbowAnimation {
    0% { background-position: 200% 0% }
    100% { background-position: 0% 0% }
}

@keyframes iconSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@-webkit-keyframes iconSpin {
  0% { -webkit-transform: rotate(0deg); }
  100% { -webkit-transform: rotate(360deg); }
}

@-moz-keyframes iconSpin {
  0% { -moz-transform: rotate(0deg); }
  100% { -moz-transform: rotate(360deg); }
}

@-ms-keyframes iconSpin {
  0% { -ms-transform: rotate(0deg); }
  100% { -ms-transform: rotate(360deg); }
}

@-o-keyframes iconSpin {
  0% { -o-transform: rotate(0deg); }
  100% { -o-transform: rotate(360deg); }
}

html, body {
  background: $bg;
  height: 100%;
  font-size: 1.1em;
  margin: 0;
  padding: 0;
  font-family: 'Ubuntu';
}

p {
  position:fixed;
  bottom:1em;
  width:100%;
  text-align:center;
  color: $link-color;
}

.main {
  width: 100%;
  height: 100%;
  justify-content: center;
  -webkit-justify-content: center;
  -moz-justify-content: center;
  display: flex;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flex;
  flex-direction: row;
  -webkit-flex-direction: row;
  -moz-flex-direction: row;
  -ms-flex-direction: row;
  align-items: center;
  -webkit-align-items: center;
}

.links {
  position: relative;
  color: $link-color;
  .link-signin {
    font-size: 1.2em;
    text-transform: uppercase;
    text-decoration: none;
  }
  .link-forgot {
    font-size: .8em;
  }
  a {
    vertical-align: middle;
    padding: 1em 2.8em;
    color: inherit;
  }
}

#signin-form {
  
  &:target {
    & > .backdrop {
      display: block;
    }
    
    & > form {
      transform: scale(1);
      -webkit-transform: scale(1);
      -moz-transform: scale(1);
      -ms-transform: scale(1);
      -o-transform: scale(1);
      opacity: 1;
    }
    
  }
  
  & > .backdrop {
    display: none;
    position: fixed;
    z-index:9;
    top:-99em; left: -99em; right: -99em; bottom: -99em;
    background: transparent;
    
    & > a {
      display: block;
      height: 100%; width: 100%;
    }
   
  }
 
  & > form {
    
    &:after {
      content: '';
      position:absolute;
      width:0;height:0;
      top:calc(100% - 1px);
      border: 16px solid;
      border-color: $form-bg transparent transparent transparent;
    }
    
    border-radius: .25em;
    -webkit-border-radius: .25em;
    -moz-border-radius: .25em;
    z-index:10;
    opacity: 0;
    position: absolute;
    width: 15em;
    top: -8.2em;
    left: 2em;
    background: $form-bg;
    padding: 1em;
    transform: scale(0);
    -webkit-transform: scale(0);
    -moz-transform: scale(0);
    -ms-transform: scale(0);
    -o-transform: scale(0);
    transform-origin: 15% 115%;
    -webkit-transform-origin: 15% 115%;
    -moz-transform-origin: 15% 115%;
    -ms-transform-origin: 15% 115%;
    -o-transform-origin: 15% 115%;
    transition: all .1s ease-in;
    -webkit-transition: all .1s ease-in;
    -moz-transition: all .1s ease-in;
    -o-transition: all .1s ease-in;
  }
    
}

.input {
  
  & > *:first-child {
    border-top-left-radius: .25em;
    -webkit-border-top-left-radius: .25em;
    -moz-border-top-left-radius: .25em;
    border-bottom-left-radius: .25em;
    -webkit-border-bottom-left-radius: .25em;
    -moz-border-bottom-left-radius: .25em;
  }
  
  & > *:nth-last-child(2) {
    border-top-right-radius: .25em;
    -webkit-border-top-right-radius: .25em;
    -moz-border-top-right-radius: .25em;
    border-bottom-right-radius: .25em;
    -webkit-border-bottom-right-radius: .25em;
    -moz-border-bottom-right-radius: .25em;
  }
  
  .tooltip {
    border-radius: .25em;
    -webkit-border-radius: .25em;
    -moz-border-radius: .25em;
    display: block;
    opacity:0;
    transform: scale(0);
    -webkit-transform: scale(0);
    -moz-transform: scale(0);
    -ms-transform: scale(0);
    -o-transform: scale(0);
    transform-origin: -5% 50%;
    -webkit-transform-origin: -5% 50%;
    -moz-transform-origin: -5% 50%;
    -ms-transform-origin: -5% 50%;
    -o-transform-origin: -5% 50%;
    transition: all .1s linear;
    -webkit-transition: all .1s linear;
    -moz-transition: all .1s linear;
    -o-transition: all .1s linear;
    background: $pink-touch;
    color: #fff;
    position: absolute;
    padding: .65em;
    margin-left: .5em;
    font-size: .8em;
    &:before {
      content: ' ';
      position: absolute;
      width:0; height:0;
      top:.9em;left:-15px;
      border:8px solid;
      border-color: transparent $pink-touch transparent transparent;
    }
  }
  
  &.error {
    .tooltip {
      transform: scale(1);
      -webkit-transform: scale(1);
      -moz-transform: scale(1);
      -ms-transform: scale(1);
      -o-transform: scale(1);
      opacity: 1;
    }
    .icon {
      color: #fff;
      background: $pink-touch;
      i:first-child {
        display:none;
      }
      i:nth-child(2) {
        display:block;
      }
      button {
        i:first-child {
          display:block;
        }
        i:nth-child(2) {
          display:none;
        }
      }
    }
  }
  display: flex;
  display: -webkit-flex;
  display: -moz-flex;
  display: -ms-flex;
  flex-direction: row;
  -webkit-flex-direction: row;
  -moz-flex-direction: row;
  -ms-flex-direction: row;
  width: 100%;
  padding: .25em 0;
  .icon {
    display: flex;
    display: -webkit-flex;
    display: -moz-flex;
    display: -ms-flex;
    align-items: center;
    -webkit-align-items: center;
    justify-content: center;
    -webkit-justify-content: center;
    -moz-justify-content: center;
    height: 2em; width: 2em;
    background: $grey;
    transition: all .1s linear;
    -webkit-transition: all .1s linear;
    -moz-transition: all .1s linear;
    -o-transition: all .1s linear;
    -ms-transition: all .1s linear;
    color: #847384;
    &.purple {
      background: $purple-touch;
      color: #fff;
    }
    i {
      font-size: .8em;
    }
    i:first-child {
       display: block;
    }
    i:nth-child(2) {
      display:none;
    }
    
    button {
      width: 100%; height: 100%;
      padding: 0;
      border: none;
      font-size:inherit;
      color: inherit;
      background: transparent;
      i:first-child {
        display: block;
      }
      i:nth-child(2) {
        display: none;
      }
      &:hover {
        cursor:pointer;
        background: rgba(255,255,255,.1);
      }
      &:focus {
        outline: none;
      }
      &.active {
        i:first-child {
          display: none;
        }
        i:nth-child(2) {
          display: block;
        }
      }
    }
    
  }
}

input {
  flex:1;
  -moz-flex:1;
  -ms-flex:1;
  -webkit-flex:1;
  padding-left: .9em;
  font-size: .7em;
  border: none;
  border-radius: 0;
  -webkit-border-radius: 0;
  -moz-border-radius: 0;
  &:focus {
    outline:none;
  }
}

#refresh-icon {
  animation: iconSpin 1s linear infinite;
  -webkit-animation: iconSpin 1s linear infinite;
  -moz-animation: iconSpin 1s linear infinite;
  -ms-animation: iconSpin 1s linear infinite;
  -o-animation: iconSpin 1s linear infinite;
}
 
* {
  box-sizing: border-box;
  -webkit-box-sizing: border-box;
  -moz-box-sizing: border-box;
}




              
            
!

JS

              
                /* Basic addClass and removeClass function like in jQuery, but I didn't use it here */
function addClass (el,className) {
  if (!el.getAttribute('class') || el.getAttribute('class').indexOf(className) < 0) {
    el.setAttribute('class',el.getAttribute('class') + ' ' + className);
  }
}

function removeClass (el,className) {
  if (el.getAttribute('class') && el.getAttribute('class').indexOf(className) > 0) {
    el.setAttribute('class',el.getAttribute('class').replace(' '+className, ''));
  }
}

/* The function launched to submit the form */
function submitForm (form,btn) {
  event.preventDefault();
  
  var rainbow = document.querySelector(form+' .rainbow');
  var inputs = document.querySelectorAll(form+' input');
  addClass(rainbow, 'active');
  addClass(btn, 'active');
 
  /* This is a timeout to fake the waiting of a server response */
  setTimeout(function(){
    for (var i=0; i<inputs.length; i++) {
      if(!inputs[i].value || inputs[i].value !== 'demo') {
        addClass(inputs[i].parentNode,'error');
      }
    }
    removeClass(rainbow, 'active');
    removeClass(btn, 'active');
  }, 1500);
  
}

/* Because it's better to see the signin panel at start, I faked a click here... */
setTimeout(function () { document.querySelector('a.link-signin').click(); }, 500);
              
            
!
999px

Console