JSFiddle - React, Tailwind, and code Playground

Slide in Log-in Form

by Jennifer Perrin

HTML

<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Yanone+Kaffeesatz:400,700,300,200"/>

<form id="slide">
  <h3>Ready? Set... Log In!</h3>
    <ul>
        <li><label for="username">Username</label><input type="text" id="username" name="username" placeholder="and you are?"></li>
        <li><label for="password">Password</label><input type="password" id="password" name="password" placeholder="the secret pass..."></li>
        <li class="actions"><a href="#" class="btn nice full small green">Login</a></li>
    </ul>
    <div class="trigger" >Login<span></span></div>
</form>

CSS

* { margin: 0; padding: 0; }
body {
    font-family: "Yanone Kaffeesatz";
    font-size: 13px;
}

form ul {
    width: auto;
    overflow: hidden;
    margin-bottom: 12px;
}
    form li {
        float: left;
        margin-right: 12px;
        list-style: none;
    }
    label {
        display: block; 
        margin-bottom: 3px;
        font-size: 16px;
    }

h3 {
    font-size: 28px;
    color: #607c8c;
    text-shadow: 0 1px 1px rgba(255,255,255,1);
    margin-bottom: 12px;
}

#slide {
    position: relative;
    top: 0;
    left: 20px;
    width: 500px;
    padding: 20px;
    background: #f0f0f0;
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 4px;
}
    #slide.down {
        -webkit-box-shadow: 2px 2px 4px rgba(0,0,0,.15);
           -moz-box-shadow: 2px 2px 4px rgba(0,0,0,.15);
             -o-box-shadow: 2px 2px 4px rgba(0,0,0,.15);
                box-shadow: 2px 2px 4px rgba(0,0,0,.15);
    }
    #slide .trigger {
        display:  block;
        position: absolute;
        left: 20px;
        bottom: -35px;
        padding: 9px 40px 0 25px;
        width: 80px;
        height: 26px;
        text-decoration: none;
        color: #777;
        font-family: georgia;        
        background: #f0f0f0;
        font-style: italic;
        border-bottom-right-radius: 4px;
        border-bottom-left-radius: 4px;
        -webkit-box-shadow: 2px 2px 4px rgba(0,0,0,.15);
           -moz-box-shadow: 2px 2px 4px rgba(0,0,0,.15);
             -o-box-shadow: 2px 2px 4px rgba(0,0,0,.15);
                box-shadow: 2px 2px 4px rgba(0,0,0,.15);
}

input[type=text], input[type=password] {
    width: 175px;
    height: 22px;
    padding: 3px 0 0 4px;
    font-family: "Yanone Kaffeesatz";    
    -webki-appearance: none;
    -moz-appearnce: none;
    outline: none !important;
    border-radius: 2px;
    border: 1px solid #ccc;
    -webkit-box-shadow: inset 2px 2px 2px rgba(0,0,0,.1);
       -moz-box-shadow: inset 2px 2px 2px rgba(0,0,0,.1);
       ...

JavaScript

jQuery(function($) {
    var top = $("#slide").outerHeight();
    $('#slide').css('top','-'+top+'px');
    $('.trigger').css('cursor','pointer');
    $('form .btn').css("margin-top", $('form label').outerHeight() + 2);

    $('.trigger').toggle(function() {
        $(this).addClass('open')
        .html('Cancel<span></span>')
        .parent()
        .toggleClass('down')
        .animate({
                'top': '0'
            }, 500);
    }, function() {
        $(this)
        .removeClass('open')
        .html('Login<span></span>')
        .parent()            
        .animate({
            'top': '-'+top+'px'
            }, 500, function() {
                $(this).toggleClass('down');
            });
    });
});