I want to create a placeholder mixin as follows. However, this fails to compile in LESS version 1.7.0.
.placeholder(...) {
::-webkit-input-placeholder: @arguments;
:-moz-placeholder: @arguments;
::-moz-placeholder: @arguments;
:-ms-input-placeholder: @arguments;
}
CSS only provides the styling, it can not remove the actual placeholder. What you can do it, set the placeholder text color as your background color of textbox, so it will look like you don't have placeholder..
The simplest way of auto-hiding a placeholder text upon focus is using the onfocus and onblur events with the <input> element.
In most of the browsers, placeholder texts are usually aligned in left. The selector uses text-align property to set the text alignment in the placeholder. This selector can change browser to browser.
Mixin allows for any placeholder css rules.
.placeholder(@rules) {
&::-webkit-input-placeholder {
@rules();
}
&:-moz-placeholder {
@rules();
}
&::-moz-placeholder {
@rules();
}
&:-ms-input-placeholder {
@rules();
}
}
Example usage:
.placeholder({
color: #0000FF;
text-transform: uppercase;
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With