The Wayback Machine - https://web.archive.org/web/20241001081615/https://www.geeksforgeeks.org/how-to-make-responsive-sliding-login-and-registration-form-using-html-css-and-javascript/
Open In App

How to make responsive sliding login and registration form using HTML CSS and JavaScript ?

Last Updated : 30 Jul, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

In this article, we will learn how to make responsive sliding login and registration forms using HTML, CSS, and javascript. Forms are used on webpages for the user to enter their required details that further send to the server for processing. A form is also known as a web form or HTML form. In this article, you will learn to make a responsive sliding login and registration form using HTML, CSS, and JavaScript. 

The main crux of this article is to slide form in to-for(left-right) motion when clicking the buttons and this can be done using the animate() method in JQuery which is an inbuilt method in jQuery that is used to change the state of the element with CSS style.

Syntax:

(selector).animate({styles}, para1, para2, para3);

Using the animate() method in JQuery is discussed further in this article.

Example: Here is the implementation of the above-explained method.

HTML Code: First we will add HTML code to form the basic structure of the Login and Registration form.

HTML
<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content=
        "width=device-width, initial-scale=1" />
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js">
    </script>
</head>

<body>
    <div id="background">
        <div class="background-Right"></div>
        <div class="background-Left"></div>
    </div>

    <div id="slide">
        <div class="top">
            <div class="left">
                <div class="content">
                    <h2>Sign Up</h2>
                    <form method="post" 
                        onsubmit="return false;">
                        <div>
                            <input type="text" 
                                placeholder="email" /> 
                            
                            <br />
                            <input type="password" 
                                placeholder="password" />
                        </div>
                    </form>

                    <button id="LeftToRight" 
                        class="on-off">Login
                    </button>
                    
                    <button>Register</button>
                </div>
            </div>

            <div class="right">
                <div class="content">
                    <h2>Login</h2>
                    <form method="post" 
                        onsubmit="return false;">
                        <div>
                            <input type="text" 
                                placeholder="email" /> 
                            
                            <br />
                            <input type="password" 
                                placeholder="password" />
                        </div>

                        <button id="RightToLeft" 
                            class="on-off">Register
                        </button>
                        
                        <button>Login</button>
                    </form>
                </div>
            </div>
        </div>
    </div>
</body>
</html>

CSS Code: Now we will add CSS code to style the forms. Comments are provided to understand the CSS code.

style.css

CSS
body {
    height: 100%;
    overflow: hidden;
    width: 100%;
    box-sizing: border-box;
}

/* Adding background image to right side */
.background-Right {
    position: absolute;
    right: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, #000428, #004e92);
    background-size: cover;
    background-position: 50% 50%;
}

/* Adding background image to left side */
.background-Left {
    position: absolute;
    left: 0;
    width: 50%;
    height: 100%;
    background: linear-gradient(to right, #02a8a8, #4fb783);
    background-size: cover;
    background-position: 50% 50%;
}

#background {
    width: 100%;
    height: 100%;
    position: absolute;
    z-index: -3;
}

/* Slide is used to slide the form left-right
    sides when toggle on button */
#slide {
    width: 50%;
    max-height: 100%;
    height: 100%;
    overflow: hidden;
    margin-left: 50%;
    position: absolute;
    box-shadow: 0 14px 28px rgba(0, 0, 0, 0.25),
        0 10px 10px rgba(0, 0, 0, 0.22);
}

/* This make forms z-index greater
than background-image */
.top {
    width: 200%;
    height: 100%;
    position: relative;
    left: 0;
    left: -100%;
}

/* This indicates Login-form will
appear on the left side */
.left {
    width: 50%;
    height: 100%;
    background: #ffff;
    left: 0;
    position: absolute;
}

/* This indicates Register-form
    will appear on the right side */
.right {
    width: 50%;
    height: 100%;
    background: #ffff;
    right: 0;
    position: absolute;
}

/* Position the form into center
of the viewbox */
.content {
    width: 250px;
    margin: 0 auto;
    top: 30%;
    position: absolute;
    left: 50%;
    margin-left: -125px;
}

.content h2 {
    color: #4caf50;
    font-size: 35px;
}

button {
    background-color: #4caf50;
    color: white;
    width: auto;
    padding: 14px 20px;
    margin: 8px 0;
    border: none;
    cursor: pointer;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 12px 20px;
    margin: 8px 0;
    display: inline-block;
    border: 1px solid #ccc;
    box-sizing: border-box;
}

/* off class is used to indicate
the active button like login
or register button */
.on-off {
    background: none;
    color: #4caf50;
    box-shadow: none;
}

JavaScript Code: Finally, we will add javascript code, where we will use jQuery ( Javascript Framework) to slide the login and register form from left-right and vice versa.  

  • When a user clicks on #RightToLeft section i.e. register button(Login form), the outer container i.e .top section is moved by 100% on the right side by adding margin-left: +100%  and adding margin-left:0% on the slide section whose initial margin-left was +50%. This animate() method helps to show the sliding effect on the login-register form.
  • The same thing happens when the user clicks on #LeftToRight section i.e login button(Sign-Up form), the outer container i.e .top section is moved by -100% on the left side by adding margin-left: 0% whose before value was margin-left: +100% as explained above and adding margin-left:+50% on slide section whose before value was margin-left: 0% as explained above

Note: To use Jquery you just need to add Jquery CDN into the HTML code.

JavaScript
$(document).ready(function () {
    $("#RightToLeft").on("click", function () {
        $("#slide").animate({
            marginLeft: "0",
        });
        $(".top").animate({
            marginLeft: "100%",
        });
    });
    $("#LeftToRight").on("click", function () {
        $("#slide").animate({
            marginLeft: "50%",
        });
        $(".top").animate({
            marginLeft: "0",
        });
    });
});

Output: 

1




Similar Reads

Design a Responsive Sliding Login & Registration Form using HTML CSS & JavaScript
In this article, we will see how to create the Responsive Sliding Login & Registration Form using HTML CSS & JavaScript, along with understanding its implementation through the illustration. Many websites, nowadays, implement sliding login & registration forms for their sites. A Registration form is used to register or create a new acco
5 min read
Basic Registration and Login Form Using React Hook Form
In ReactJS, creating a form can be a nightmare as it involves handling inputs and validating inputs. React-hook-form is a ReactJS library that simplifies the process of creating forms. The library provides all the features that a modern form needs. It is simple, fast, and offers isolated re-renders for elements. In this article, we will learn how t
6 min read
How to Create a Responsive Login Form in Navbar using CSS?
A Responsive Login form in the Navbar allows users to log in from any page of the website without navigating to a separate login page. This article explains how to create a Responsive Login form within a Navbar using CSS. ApproachStart by creating a <nav> element to contain the navbar.Inside the <nav> create a <div> element for th
3 min read
HTML Responsive Modal Login Form
An HTML Responsive Modal Login Form is a popup form designed to request user credentials, such as a username and password, within a modal window. It adapts to different screen sizes, ensuring usability on various devices, from desktops to smartphones, without affecting the overall layout. Preview: Approach:HTML Structure: Create a button to trigger
4 min read
How to make photo sliding effect using HTML and CSS ?
It is an easy and amazing animation effect created with HTML and CSS, where the photos are moving horizontally one by one like a roller. When the mouse pointer comes upon the photo then the specific photo stops moving. Approach: The basic idea of these animation comes from the hover effect of CSS animation. Let us see how the code works. HTML code:
5 min read
How to Make Vertical Card Sliding Animation using only HTML & CSS ?
The vertical card slider serves as an engaging way to showcase content, such as profiles, products, or services, in a modern web design. In this tutorial, we'll see the creation of a visually appealing vertical card slider with smooth animation effects using HTML and CSS. Approach :Firstly use the HTML to structure the cards and their content.Now a
3 min read
Login and Registration Project Using Flask and MySQL
Project Title: Login and registration Project using Flask framework and MySQL Workbench. Type of Application (Category): Web application. Introduction: A framework is a code library that makes a developer's life easier when building web applications by providing reusable code for common operations. There are a number of frameworks for Python, inclu
6 min read
How to implement Email Registration and Login using Firebase in React?
When building a full-stack application we sometimes want to do build the authentication part quickly without writing much code, then there comes Firebase to our rescue which offers multiple authentication methods like Email-Password, Google, Facebook, etc. Following are the steps which cover how to authenticate users through email id and password i
3 min read
Sliding Window Visualizer using HTML CSS and JavaScript
Window sliding technique is used extensively in array problems and used a lot in subarray-related problems like subarray sum etc. In this article, we will understand how Sliding Window Visualizer works along with knowing the basic implementation of the visualizer. Window sliding technique is an efficient way to calculate and solve problems with con
8 min read
LinkedIn Login Form Using HTML and CSS
Nowadays, a professional website LinkedIn very popular. This UI has generally seen on the “LinkedIn” website. In this article, we will create a LinkedIn Login UI using HTML and CSS. Below are the two steps on how to do it. This will help the beginner to build some awesome UI using HTML and CSS by referring to this article. Before the code, you just
3 min read
How to Add a Login Form to an Image using HTML and CSS?
The login form on an Image is used on many websites. Like hotel websites that contain pictures of the hotels or some organizations that organize special events holding that event picture and login form. In that case, you can design a login or registration form on that picture. This design will make the website more attractive than a regular login o
2 min read
Creating a Registration and Login System with PHP and MySQL
A registration and login system is a fundamental component of many web applications and provides user authentication and security. This allows users to create an account log in with their login credentials and manage their session securely. By using PHP for server-side scripting and MYSQL for database, management we can we can efficiently handle us
13 min read
How to Create Glassmorphism Login Form in HTML and CSS ?
Glassmorphism, characterized by its transparent and frosted glass-like appearance, provides a visually appealing user interface. The login form will feature translucent backgrounds, blurred elements, and subtle shadows to achieve the Glassmorphism effect. the step-by-step process of designing and coding a stunning Glassmorphism login form that can
3 min read
How to Make Responsive Vertical Timeline Design using only HTML and CSS ?
A Timeline is a list of events according to the order of dates which is used to get an overview of various tasks and their expected timing. Crafting a responsive vertical timeline design using only HTML and CSS involves making a visually pleasing layout that arranges content chronologically in a vertical manner. To make it responsive for small devi
5 min read
How to make a HTML div responsive using CSS ?
The CSS Media Query can be used to make an HTML "div" responsive. The media queries allow the users to change or customize the web pages for many devices like desktops, mobile phones, tablets, etc without changing the markups. Using the media query, the user can change the style of a particular element for different sizes of screen. Note: The CSS @
2 min read
How to Create Sliding Text Reveal Animation using HTML & CSS ?
In this article, we will implement sliding text reveal animation which can be used in personal portfolios, websites, and even in YouTube introduction videos to add an extra edge to our videos so that it looks more interesting and eye-catchy at first instance and the best part is that we will do that using just HTML and CSS. Approach: The animation
3 min read
How to create Twitter Login Page using HTML CSS JavaScript ?
In this article, we will see How To Make a Twitter Login Page Like Using HTML CSS JavaScript. The code produces an attractive login page with a design similar to the Twitter login interface. The JavaScript incorporates straightforward validation for the email input field upon submitting the form. Preview ApproachCreate a div, button, input text, an
4 min read
How to create a Social Media Login Form using CSS ?
To create a social media login form using CSS, we will design a container with input fields for a username or password and a login button. In this social media login form, we will enhance the interface with distinct styling, and integrate social media icons or buttons for a user-friendly and visually appealing login experience. Preview: Approach:Fi
3 min read
Create a Social Media Login Form using Tailwind CSS
The social media login page allows users to log in using their email and password or through various social media platforms such as Facebook, Twitter, Google, and Instagram. Here we will create a social media login page using Tailwind CSS. PrerequisitesHTML JavaScriptTailwind CSSApproachHTML Structure: Defines the layout of the login form, includin
2 min read
How to make Form Responsive using Bootstrap ?
We are going to create a responsive form by using Bootstrap 5. responsiveness is a feature that allows users to interact with the web app on any device easily. It helps to create better UI interactions and a better user experience that can be a reason to have great traffic on the respective website. These are the following methods to make a form re
4 min read
Create a Responsive Admin Dashboard using HTML CSS and JavaScript
In this article, we will see how to create the Responsive Admin Dashboard using HTML, CSS & JavaScript, along with understanding its implementation through the illustration. This project involves structuring the HTML layout for navigation, sidebar, and content, styling with CSS to ensure responsiveness, incorporating interactive elements using
10 min read
Responsive analog clock using HTML, CSS and Vanilla JavaScript
In this article, we are going to create an Analog Clock. This is mainly based on HTML, CSS & Vanilla JavaScript. Approach: Create an HTML file in which we are going to add the main div, further on we are adding 4 div tags for an hour, minute, and second hands & for the pin.Create a CSS file for styling our web page and for assigning differe
4 min read
Create A Responsive Navbar with Icons using HTML CSS and JavaScript
The navigation bar, or Navbar is an essential component in modern web design. It allows users to navigate through a website easily. Adding icons to the navbar is not only enhances visual appeal but also improves user experience. The Responsive Navigation bar means the Navbar elements are visible on all sizes of devices i.e. in mobile devices, the n
2 min read
Design a Responsive Product Card using HTML, CSS & JavaScript
We'll create a responsive product card using HTML, CSS, and JavaScript. A product card is a basic UI element used in e-commerce websites to show product details in a simple format. We're creating a one-size-fits-all product card for online use. It's designed to work well on any screen size so it will be fully responsive. Output preview: Prerequisit
4 min read
Tailwind CSS Login Form
Login forms in Tailwind CSS are sections of a document on websites that are used for user authentication, web security, accessibility, and to gain access to restricted areas. A typical login form consists of two input fields, i.e., one for the user’s username and the other for their password. It also includes a submit button that, when clicked, sen
3 min read
Design a transparent login/Sign Up webpage using HTML and CSS
Project Introduction: In this article, we will discuss how to design a transparent login webpage using HTML and CSS. Project Structure: index.htmlstyle.css index.html Explanation: We have put the login form in a class called container and we have placed each input tag in a separate div with class row so that each input tag occupies the full line. W
3 min read
how to create a responsive checkout form using CSS
Creating a responsive checkout form using CSS ensures that users can efficiently and comfortably enter their billing and payment information on any device. ApproachCreate a form that is wrapped inside a <form> tag.Inside the form create two sections for "Address Details" and "Payment Information".Include required input fields inside the form.
3 min read
How to create a Responsive Inline Form using CSS ?
When the browser window is resized, the labels and inputs will stack on top of each other for smaller screens. To create a responsive inline form using CSS, use a container with flexible styling, such as Flexbox or Grid, to arrange form elements horizontally. Utilize media queries to adjust the layout for smaller screens, ensuring a user-friendly e
3 min read
HTML Login Form
HTML Login Form is a foundational element in web development. It is used to authenticate users and grant access to secure sections of a website or application. It typically includes input fields for username/email and password, along with a submit button for logging in. Additionally, there is often an option for new users to create an account or si
3 min read
HTML Neumorphism Login Form
Neumorphism combines developments of flat design and skeuomorphism. Neumorphism, or soft UI, is a visual style that combines background colors, shapes, gradients, highlights, and shadows to ensure graphic intense buttons and switches. All that allows achieving a soft, extruded plastic look, and almost 3D styling. For a better understanding visit: h
3 min read