H5 and CSS3 to make input boxes with hint text

Source: Internet
Author: User
WebKit unique CSS, you can control the text style inside, with CSS3 animation effect and pseudo-class, we can easily make a drive to draw the input box, in the system login, search and other locations are suitable, interested you can refer to this article may help you have not written a technical article for a long time, Recently has been to WebKit as a carrier development system, of course, the need to use a large number of HTML5 and CSS3, not only reduce a large number of JS can also guarantee smoother.

When the dialog box is selected, the prompt text becomes light and disappears after you enter it. The current practice is to add a label after the input tag. Use JS control.
After the advent of HTML5, we have a better way.

The code is as follows:

<input type= "text" placeholder= "username or mail Address" name= "username"/>

We see a placeholder tag that can be used as a user text hint. This is a very convenient way to go. But in order to be perfect, we need to make the text lighter, or modify the style of the cue file after the selection, what do we do?

The code is as follows:

Input::-webkit-input-placeholder {color: #999;-webkit-transition:color.5s;} input:focus::- Webkit-input-placeholder, Input:hover::-webkit-input-placeholder {color: #c2c2c2;-webkit-transition:color.5s;}


-webkit-input-placeholder,webkit unique CSS, you can control the text style inside, with CSS3 animation effect and pseudo-class, we can easily make a drive to draw the input box, in the system login, search and other locations are suitable. Of course you want to be compatible with IE6, this method is not feasible. However, Ie9 also supports the placeholder tag, which means that it cannot be changed by color.
So, what if I don't support it? You can simply use jquery to help, so it's not covered in this article.
A Demo,demo address must be in the WebKit browser to see the full effect. Isn't it convenient?

"Recommended"

1. CSS3 Free Video Tutorial

2. Share some of the most recent CSS3 properties that are commonly used

3. Use CSS to make chat box small sharp corner, bubble effect

4. Browser for mobile high-performance CSS3 animation

5. H5+CSS3 code instances that implement picture fly-in and fade-out effects

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.