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

Mybatis mysql delete in operation can only delete the first data method

Bugs As shown in the figure, I started to copy th...

Introduction to MySQL database performance optimization

Table of contents Why optimize? ? Where to start?...

Implementation of Docker data volume operations

Getting Started with Data Volumes In the previous...

Understand the basics of Navicat for MySQL in one article

Table of contents 1. Database Operation 2. Data T...

Detailed explanation of JavaScript Promise and Async/Await

Table of contents Overview Four examples Example ...

Vue imports Echarts to realize line scatter chart

This article shares the specific code of Vue impo...

Summary of several submission methods of HTML forms

The most common, most commonly used and most gener...

...

How to install MySQL 8.0 and log in to MySQL on MacOS

Follow the official tutorial, download the instal...

Analysis and application of irregular picture waterfall flow principle

The layout problem of irregular picture walls enc...

JavaScript BOM Explained

Table of contents 1. BOM Introduction 1. JavaScri...

MySQL 4 methods to import data

1. Import mysql command The mysql command import ...