How To Create A Login Form With Floating Placeholder Using HTML and CSS

How To Create A Login Form With Floating Placeholder Using HTML and CSS


Welcome to my website U-GINE MEDIA. In this website I teach tutorials and share source code on some programming (HTML, CSS & JavaScript) tutorials. 

Before we get started, do well to subscribe to my channel to never miss out on any update that I post every single day.

In this tutorial topic "How To Create A Login Form With Floating Placeholder Using HTML and CSS", we will learn how to create it following these simple easy steps.

Share this to your programmer friends. If y'all learnt something today, make sure to let me in the comments. 

If interested in watching the video before running the code below, you can click the play button to get started.




Code Begins

  1. First, create a folder with any name you like. Then, make the necessary files inside it.
  2. Create a file called index.html to serve as the main file.
  3. Create a file called style.css for the CSS code.

To start, add the following HTML codes to your index.html file. These codes include essential HTML markup with different semantic tags, such as div, form, input, button, image, etc., to build the website layout. 


<!DOCTYPE html>
<html lang="en">
<head>
    <link rel="stylesheet" href="index.css">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Login Form With Floating Placeholder</title>
</head>
<body>

    <div class="login_box">
        <h2>Login</h2>
        <form>
            <div class="user_box">
                <input type="text" required>
                <label>Username</label>
            </div>
            <div class="user_box">
                <input type="password" required>
                <label>Password</label>
            </div>
            <a href="#">
                <span></span>
                <span></span>
                <span></span>
                <span></span>
                Submit
            </a>
        </form>
    </div>

</body>
</html>

Finally, add the following CSS codes to your style.css file to make your AI image generator website beautiful and user-friendly. You can customize the different CSS properties, such as color, background, font, etc., to give a personalized touch to your website. 



//paste code here
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    height: 100%;
}

body {
    font-family: sans-serif;
    background: #243b55;
}

.login_box {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 400px;
    padding: 40px;
    transform: translate(-50%,-50%);
    background: rgba(0,0,0,.5);
    box-shadow: 0 15px 25px rgba(0,0,0,.8);
}

.login_box h2 {
    margin: 0 0 30px;
    padding: 0;
    color: #fff;
    text-align: center;
}

.login_box .user_box {
    position: relative;
}

.login_box .user_box input {
    width: 100%;
    padding: 10px 0;
    font-size: 16px;
    color: #fff;
    margin-bottom: 30px;
    border: none;
    border-bottom: 1px solid #ffff;
    outline: none;
    background: transparent;
}

.login_box .user_box label {
    position: absolute;
    top: 0;
    left: 0;
    padding: 10px 0;
    font-size: 16px;
    color: #fff;
    pointer-events: none;
    transition: .5s;
}

.login_box .user_box input:focus ~ label,
.login_box .user_box input:valid~label {
    top: -20px;
    left: 0;
    color: #03e9f4;
    font-size: 12px;
}

.login_box form a {
    position: relative;
    display: inline-block;
    padding: 10px 20px;
    color: #03e9f4;
    font-size: 16px;
    text-decoration: none;
    text-transform: uppercase;
    overflow: hidden;
    transition: .5s;
    margin-top: 50px;
    letter-spacing: 4px;
}

.login_box a:hover {
    background: #03e9f4;
    color: #fff;
    border-radius: 5px;
    box-shadow: 0 0 5px #03e9f4,
                0 0 25px #03e9f4,
                0 0 50px #03e9f4,
                0 0 100px #03e9f4;
}

.login_box a span {
    position: absolute;
    display: block;
}

.login_box a span:nth-child(1) {
    top: 0;
    left: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, #03e9f4);
    animation: btn_anime1 1s linear infinite;
}

@keyframes btn_anime1 {
    0% {
        left: -100%;
    }50%,100% {
        left: 100%;
    }
}

.login_box a span:nth-child(2) {
    top: -100%;
    right: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(180deg, transparent, #03e9f4);
    animation: btn_anime2 1s linear infinite;
    animation-delay: .25s;
}

@keyframes btn_anime2 {
    0% {
        top: -100%;
    }50%,100% {
        top: 100%;
    }
}

.login_box a span:nth-child(3) {
    bottom: 0;
    right: -100%;
    width: 100%;
    height: 2px;
    background: linear-gradient(270deg, transparent, #03e9f4);
    animation: btn_anime3 1s linear infinite;
    animation-delay: .5s;
}

@keyframes btn_anime3 {
    0% {
        right: -100%;
    }50%,100% {
        right: 100%;
    }
}

.login_box a span:nth-child(4) {
    bottom: -100%;
    left: 0;
    width: 2px;
    height: 100%;
    background: linear-gradient(360deg, transparent, #03e9f4);
    animation: btn_anime4 1s linear infinite;
    animation-delay: .75s;
}

@keyframes btn_anime4 {
    0% {
        bottom: -100%;
    }50%,100% {
        bottom: 100%;
    }
}


Conclusion and Final word

Now, we have reached the end of our code, for any information, you can comment any problem or code-not-working issues to resolve it, am always with you. You can also visit my YouTube Channel for more updates on HTML, CSS & JavaScript Designs. I believe you can create "A Login Form With Floating Placeholder Using HTML and CSS". and do so much more with codes. Go extremely far in exploring the world of HTML, CSS & JavaScript, its gonna be fun, trust me 😃.

Happy Coding Journey 🚀

Post a Comment

0 Comments

Close Menu