CSS Change Placeholder color. Appearance of the names of the fields or how to change Placeholder
In an effort to reduce the form and reduce visual noise, designers tag
bad
Okay
Stylization: Change Color Placeholder CSS
Change input field style with Placeholder CSS
bad
PLACEHOLDER EFFECT FOR
PLACEHOLDER attribute only works for and
Ancient Memory Method Changing Value JavaScript
PLACEHOLDER attribute is used to create prompts inside empty input fields (tags and
Let's start with the example for those who still do not know what Playsholder is and how to use it:
When developing interfaces, the features of the behavior of playholders should be taken into account. The text of the playerholeder disappears as soon as the input begins. That is why it is not necessary to use them to transmit information about the input field itself (how many and which characters it should contain). For these purposes it is best to use the tag or paragraph with a small tip. Learn more about the features of the use of player choleders can be read.
Stylization
The following rules are used to stylize player choleders:
Looks terrible, right? And there is a reason for this - until now, CSS rules for playing holders were not standardized and implementing in each browser is different. Read more about all the necessary prefixes can be found at Caniuse.
If you are using a CSS preprocessor, then most likely, for the use of styles to filmholders, you will be most convenient to write simple mixing. Example on SASS:
Not every CSS property can be used with playcold. Here is a complete list of supported properties:
font and all related properties (font-size, font-family, etc.)
background and all related properties (Background-Color, Background-image, etc.)
opacity
text-Indent
text-Overflow.
color
text-transform
line-Height
word-Spacing
letter-Spacing
text-Decoration.
vertical-align
Animation
Animation ideas belong to HTML5.BY blog.
All the following examples are written using the SASS preprocessor. Each is attached with a link to SassMeister, which you can find the compiled CSS code.
Most likely, you want to apply animations to filmholders when focus on the input field. All this is done quite simple. Just just a few times used by the previously Mixin Placeholder:
.input (@include Placeholder ( // Styles for normal state ) &: Focus (@include Placeholder ( // Styles after Focus Event }
}
}
The greater the input field width, the greater the value of the Text-Indent property must be. For the standard input field, 500px will be enough, for wider it is necessary to pick up manually. From the width of the input field and the TEXT-INDENT value depends on the speed of the animation. To shift, you need to use negative values, for example -500px.
Shift down
As in the last example, the animation depends on the size of the will of the input, but in this case the attention is paid to the height. For the overwhelming majority input fields, the desired Line-Height value will be within 100px. Unfortunately, using the Line-Height property, it is impossible to implement the shift effect up, as the property does not accept negative values.
To use the animation code for playcolders, it was pleasant and convenient, you can write a small library of mixes for any preprocessor. The library looks like this ():
It is very simple to use it. It is enough to connect the desired mixing to any field input field or simply create one global rule for all PAYSHoleders on the page:
// for individual elements.pl-shift-right (@include pl-shift (right);) .pl-Fade-Out (@include Pl-Fade-Out;) // for the rest@include pl-shift (left);
Autoprefixer.
If you do not use the preprocessor and still do not want your source CSS file to turn into porridge from prefixes for all possible browsers, then pay attention to AutoPrefixer. With it, pure CSS can be made dirty (but already in another file) by adding all the necessary prefixes to all properties. To force the plugin to work with Passyholders, it is enough to use a pseudo-element :: Placeholder:
After the battery parsing, Autoprefixer will create a separate CSS file, which will write all the necessary prefixes for all the browser you specified.
What's next
As I have already written above, everything that is connected with the use of styles to playswords is not yet standardized. It will be corrected soon. The SELECTOR LEVEL 4 specification was added pseudo-class: Placeholder-Shown, which will finally lead to the standard all the insane mixture of pseudoclass and pseudo-elements that exists now. You can follow the support for CANIUSE (now is not supported in any browser).
Apply styles with: Placeholder-Shown will be much simpler:
.input: Placeholder-Shown (Color: Blue;)
The Placeholder attribute is used to call for action inside the empty elements input and Textarea. In this article, we will consider the ability to stylize the text Placeholder-A, as well as some tricks that will make it more comfortable and functional.
So, let's start with the example for those who do not know what Placeholder is.
hTML.
PLACEHOLDER-A style can be changed using such a set of CSS rules:
It looks scary, isn't it? The fact is that this is still not in standards. Each browser has implemented support for the stylization of Placeholder.
In IE and the old Firefox (until the 18th) Placeholder is considered a pseudolass, and in the new Firefox, WebKit and Blink - pseudo-element.
We look at what happened:
It must be said that not all possible CSS properties are supported. Most modern browsers allow you to change:
font (and related properties)
background (and related properties)
color
word-Spacing
letter-Spacing
text-Decoration.
vertical-align
text-transform
line-Height
text-Indent
text-Overflow.
opacity
And if Placeholder does not fit?
Sometimes field entry fields are reduced by width due to the features of Laouta, in particular on mobile devices. In this case, the long text of PlaceHolder-A will be ugly cut. To prevent this, you can use Text-overflow: Ellipsis. Such a syntax will work in all new browsers.
I hope it will come in handy. Write comments and suggestions in the comments.
Playcoleder is an element of the input field in which you can place a hint. When the user begins to enter data, the auxiliary text disappears to not interfere. Each browser has its own opinion on the account of how this element should be displayed, and sometimes the default styles break the entire design. To manage them, you need to use the special CSS Placeholder rule.
Where is Playcoleder?
The problem is that the hint of the input field is securely hidden in the DOM shadow, and it's not so easy to get to it. This uses a special non-standard :: Placeholder. With it, you can control the properties of the prompt.
The stylization of Placeholder on CSS looks like this:
The CSS Placeholder's pseudo-element is well processed by all modern browsers, and to support old browsers, you can use the prefixes:
:: - WebKit-Input-Placeholder - for WebKit Browser (Safari, Chrome, Opera);
:: - MOZ-PLACEHOLDER - for Firefox browsers above 19 versions;
: -Moz-Placeholder - for old Firefox;
: -MS-input-Placeholder - for Internet Explorer above 10 version.
As can be seen, old Mozilla browsers, as well as IE, consider Placeholder CSS-pseudoclass, not a pseudo-element. We will not argue with them, just take into account this aspect when styling the input field.
Stylization opportunities
For a pseudo-element Placeholder in CSS you can set the following parameters:
background - group of prompts block applies to all input field. You can specify not only the color (Background-color), but also image (background-image).
text color - Color;
transparency - OPACITY;
underlining, undarching or overlooking - text-decoration;
register - TEXT-TRANSFORM;
internal indents - padding. It is not supported by all browsers. As for lowercase elements, the upper and lower indentes are ignored.
font Display - Properties of the Font, Line-Height group and a variety of indents (text-indentent, letter-spacing, word-spacing);
vertical alignment in the string - vertical-align;
trimming text when the container is overflowing - Text-overflow.
By default, the tip disappears from the input field only if at least one character is entered into it. But Placeholder allows you to make the disappearance immediately when focusing on the field. To do this, combine it with a pseudolass: Focus.
INPUT: Focus :: Placeholder (Color: Transparent;)
In some browsers, it is permissible to adjust the change in the specification of the playerholeder using the Transition instruction.
In the Google Chrome browser, the color of the prompts when focusing on such a field will change smoothly for one second.
Playcoleder is an element of the input field in which you can place a hint. When the user begins to enter data, the auxiliary text disappears to not interfere. Each browser has its own opinion on the account of how this element should be displayed, and sometimes the default styles break the entire design. To manage them, you need to use the special CSS Placeholder rule.
Where is Playcoleder?
The problem is that the hint of the input field is securely hidden in the DOM shadow, and it's not so easy to get to it. This uses a special non-standard pseudo-element CSS :: PLACEHOLDER. With it, you can control the properties of the prompt.
You Will Be intended:
The stylization of Placeholder on CSS looks like this:
The CSS Placeholder's pseudo-element is well processed by all modern browsers, and to support old browsers, you can use the prefixes:
:: - WebKit-Input-Placeholder - for WebKit Browser (Safari, Chrome, Opera);
:: - MOZ-PLACEHOLDER - for Firefox browsers above 19 versions;
: -Moz-Placeholder - for old Firefox;
: -MS-input-Placeholder - for Internet Explorer above 10 version.
As can be seen, old Mozilla browsers, as well as IE, consider Placeholder CSS-pseudoclass, not a pseudo-element. We will not argue with them, just take into account this aspect when styling the input field.
Stylization opportunities
For a pseudo-element Placeholder in CSS you can set the following parameters:
background - group of background properties. The background of the prompt block applies to the entire input field. You can specify not only the color (Background-color), but also image (background-image).
text color - Color;
transparency - OPACITY;
underlining, undarching or overlooking - text-decoration;
register - TEXT-TRANSFORM;
internal indents - padding. It is not supported by all browsers. As for lowercase elements, the upper and lower indentes are ignored.
font Display - Properties of the Font, Line-Height group and a variety of indents (text-indentent, letter-spacing, word-spacing);
vertical alignment in the string - vertical-align;
trimming text when the container is overflowing - Text-overflow.
By default, the tip disappears from the input field only if at least one character is entered into it. But the CSS Placeholder's pseudo-element allows you to make the disappearance immediately when focusing on the field. To do this, combine it with a pseudolass: Focus.
iNPUT: Focus :: Placeholder (Color: Transparent;)
In some browsers, it is permissible to adjust the change in the specification of the playerholeder using the Transition instruction.