Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS LESS Placeholder Mixin

Tags:

css

mixins

less

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;
}
like image 638
Aydus-Matthew Avatar asked May 19 '14 01:05

Aydus-Matthew


People also ask

How do you make a placeholder invisible in CSS?

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..

How do you hide the placeholder text of an input field Pick one or more options?

The simplest way of auto-hiding a placeholder text upon focus is using the onfocus and onblur events with the <input> element.

How do I change placeholder position in CSS?

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.


1 Answers

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;
});
like image 93
Aydus-Matthew Avatar answered Nov 15 '22 23:11

Aydus-Matthew