The implementation code of the CSS3 input box is similar to the animation effect of Google login

The implementation code of the CSS3 input box is similar to the animation effect of Google login

Use CSS3 to animate the input box similar to the Google login page

Effect 1

insert image description here

The code is as follows

CSS

body{
    background-color:#acacac;
  }
  .form-container{
    display: block;
    position: relative;
    width: 400px;
    height: 400px;
    background: #fff;
    margin: 50px auto;
    padding: 30px;
  }

  input{
    display: block;
    position: relative;
    background: none;
    border: 2px solid #acacac;
    border-radius:5px;
    width: 100%;
    font-weight: bold;
    padding-left:10px;
    font-size: 16px;
    height:35px;
    z-index: 1;
  }

  label{
    display: inline-block;
    position: relative;
    top: -32px;
    left: 10px;
    color: #acacac;
    font-size: 16px;
    z-index: 2;
    transition: all 0.2s ease-out;
  }

  input:focus, input:valid{
    outline: none;
    border: 2px solid #00aced;
  }

  input:focus + label, input:valid + label{
    top: -50px;
    font-size: 16px;
    color: #00aced;
    background-color:#fff;
  }

HTML

<div class="main">
    <div class="form-container">
      <input type="text" name="input1" required>
      <label for="input1">Account</label>

      <input type="text" name="input2" required>
      <label for="input2">Password</label>
    </div>
  </div>

Effect 2

insert image description here

The code is as follows:

CSS

body{
    background-color:#acacac;
  }
  .form-container{
    display: block;
    position: relative;
    width: 400px;
    background: #fff;
    margin: 50px auto;
    padding: 60px;
  }

  input{
    display: block;
    position: relative;
    background: none;
    border: none;
    border-bottom: 1px solid #ddd;
    width: 100%;
    font-weight: bold;
    font-size: 16px;
    z-index: 2;
  }

  label{
    display: block;
    position: relative;
    top: -20px;
    left: 0px;
    color: #999;
    font-size: 16px;
    z-index: 1;
    transition: all 0.3s ease-out;
    margin-bottom:40px;
  }

  input:focus, input:valid{
    outline: none;
    border-bottom: 1px solid #00aced;
  }

  input:focus + label, input:valid + label{
    top: -50px;
    font-size: 16px;
    color: #00aced;
    background-color:#fff;
  }

HTML

<div class="main">
    <div class="form-container">
      <input type="text" name="input1" required>
      <label for="input1">Account</label>
      <input type="text" name="input2" required>
      <label for="input2">Password</label>
    </div>
  </div>

Summarize

This concludes this article about the implementation code of the CSS3 input box with animation effects similar to Google login. For more related CSS3 input box content, please search 123WORDPRESS.COM’s previous articles or continue to browse the related articles below. I hope everyone will support 123WORDPRESS.COM in the future!

<<:  10 issues that must be considered when designing and building large-scale website architecture

>>:  Simple understanding and examples of MySQL index pushdown (ICP)

Recommend

JavaScript to achieve custom scroll bar effect

In actual projects, the up and down scroll bars a...

How to design the homepage of Tudou.com

<br />I have been working in front-end for s...

Detailed explanation of webpage screenshot function in Vue

Recently, there is a requirement for uploading pi...

Two ideas for implementing database horizontal segmentation

introduction With the widespread popularity of In...

20 CSS coding tips to make you more efficient (sorted)

In this article, we would like to share with you ...

MySQL 8.0.18 Installation Configuration Optimization Tutorial

Mysql installation, configuration, and optimizati...

Docker deployment springboot project example analysis

This article mainly introduces the example analys...

Vue implements Modal component based on Teleport

Table of contents 1. Get to know Teleport 2. Basi...

How to view Linux ssh service information and running status

There are many articles about ssh server configur...

A simple example of using Vue3 routing VueRouter4

routing vue-router4 keeps most of the API unchang...

MySQL operations: JSON data type operations

In the previous article, we introduced the detail...

IE conditional comments for XHTML

<br />Conditional comments are a feature uni...

SQL implementation of LeetCode (197. Rising temperature)

[LeetCode] 197.Rising Temperature Given a Weather...

Practical basic Linux sed command example code

The Linux stream editor is a useful way to run sc...