Use CSS3 to animate the input box similar to the Google login page Effect 1 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 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)
Bugs As shown in the figure, I started to copy th...
Table of contents Why optimize? ? Where to start?...
Getting Started with Data Volumes In the previous...
Table of contents 1. Database Operation 2. Data T...
Table of contents Overview Four examples Example ...
This article shares the specific code of Vue impo...
Table of contents transition hook function Custom...
The most common, most commonly used and most gener...
Follow the official tutorial, download the instal...
The layout problem of irregular picture walls enc...
Encryption and decryption are an important means ...
Table of contents 1. BOM Introduction 1. JavaScri...
Big pit, don't easily delete the version of P...
1. Import mysql command The mysql command import ...