Sliding Login

HTML
<!-- Static container --> <div class="container container--static"> <!-- Signup prompt --> <div class="info-box left"> <h2 class="heading">Don't have an account?</h2> <p class="info-text">Ethical celiac hashtag taxidermy squid. Wayfarers distillery narwhal, kombucha jean shorts selvage meggings.</p> <button class="button button--signup">Sign up</button> </div> <!-- Login prompt --> <div class="info-box right"> <h2 class="heading">Have an account?</h2> <p class="info-text">Ethical celiac hashtag taxidermy squid. Wayfarers distillery narwhal, kombucha jean shorts selvage meggings.</p> <button class="button button--login">Login</button> </div> </div> <!-- Sliding container --> <div class="container container--sliding"> <!-- Login --> <div class="slider-content login"> <h2 class="heading alt">Log In</h2> <form id="login"> <input class="email" type="text" placeholder="Email"> <input class="password" type="password" placeholder="Password"> </form> <button class="button button--login alt">Log In</button> <p class="info-text alt"><a href="">Forgot password?</a></p> </div> <!-- Signup --> <div class="slider-content signup"> <h2 class="heading alt">Sign Up</h2> <form id="signup"> <input class="name" type="text" placeholder="Full Name"> <input class="email" type="text" placeholder="Email"> <input class="password" type="password" placeholder="Password"> </form> <button class="button button--signup alt">Sign Up</button> </div> </div>
SCSS
/* Inspired by Deepak's shot (https://dribbble.com/shots/2311260-Day-1-Sign-Up-and-Login-Animated-Download-Template) */ $alt: #E26A6A; body { background: url(https://images.unsplash.com/photo-1443890923422-7819ed4101c0?crop=entropy&fit=crop&fm=jpg&h=650&ixjsv=2.1.0&ixlib=rb-0.3.5&q=80&w=1375) no-repeat center center fixed; -webkit-background-size: cover; -moz-background-size: cover; -o-background-size: cover; background-size: cover; font-family: 'Montserrat'; overflow: auto; } a, a:focus, a:visited, a:active { text-decoration: none; color: inherit; } .container { padding: 5%; border-radius: 3px; } .container.container--static { width: 80%; min-width: 600px; height: 40%; min-height: 250px; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); background-color: #000; color: #eee; opacity: 0.6; } .container.container--sliding { width: 35%; height: 50%; min-height: 300px; background-color: #fefefe; position: absolute; top: 50%; left: 65%; transform: translate(-50%, -50%); box-shadow: 3px -2px 6px 0px rgba(0, 0, 0, 0.4); & .slider-content.signup { display: none; } } .info-box { width: 40%; margin: 5% auto; } .info-box.left { float: left; } .info-box.right { float: right; } .heading { font-family: 'Montserrat'; font-size: 1.2em; } .heading.alt { margin-bottom: 10%; text-transform: uppercase; color: $alt; } .info-text { font-family: 'Roboto'; font-size: 0.7em; font-weight: 300; letter-spacing: 1px; } .info-text.alt { color: #aaa; } .button { width: 35%; margin-top: 15px; padding: 2% 5%; background-color: transparent; color: #eee; border: 2px solid #ccc; border-radius: 3px; font-family: 'Montserrat'; font-size: 0.7em; text-transform: uppercase; cursor: pointer; } .button.alt { margin-bottom: 15px; background-color: $alt; border: 0; } .button:focus { outline: 0; } form { margin-bottom: 10%; } form input { display: block; width: 100%; margin-bottom: 15px; padding: 5px; border: 0; border-bottom: 2px solid #ddd; font-family: 'Montserrat'; &:focus { outline: 0; } }
JAVASCRIPT
/* Inspired by Deepak's shot (https://dribbble.com/shots/2311260-Day-1-Sign-Up-and-Login-Animated-Download-Template) */ (function() { var signup = $('.container--static .button--signup'); var login = $('.container--static .button--login'); var signupContent = $('.container--sliding .slider-content.signup'); var loginContent = $('.container--sliding .slider-content.login'); var slider = $('.container--sliding'); signup.on('click', function() { loginContent.css('display', 'none'); signupContent.css('display', 'initial'); slider.animate({ 'left': '30%' }, 350, 'easeOutBack'); }); login.on('click', function() { signupContent.css('display', 'none'); loginContent.css('display', 'initial'); slider.animate({ 'left': '70%' }, 350, 'easeOutBack'); }); })();
Expand for more options Login