L
L
Lenar Fattakhov2015-01-29 15:40:33
css
Lenar Fattakhov, 2015-01-29 15:40:33

How to center align placeholder in android browser?

I noticed a feature of the browser on android, its input placeholder is always left-aligned. Can this be fixed?
Any "::-webkit-input-placeholder" doesn't work here(
<input type="text" placeholder="Наш placeholder">

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Denis Artemiev, 2015-01-29
@ArtDenis

Of course, I don’t pretend to be a solution:
Instead of a placeholder, I sometimes do this:

var tel = 'Ваш номер телефона*';

        $('#tel').val(tel);

        $('#tel').focus(function(){
            if($('#tel').val() == tel)
                $(this).val('');
        });

        $('#tel').blur(function(){
            if($(this).val() == ''){
                $(this).val(tel);
            }
        });

When loading, we put the value of the tel variable in our input.
Then, when you click on the input, we clear it if there is a text for the tel variable.
And if after moving the cursor away from the input we have an empty field, then we put tel there.
Disadvantage: unlike placeholder, when you press it, you can’t see what you need to enter (Although I think if you replace focus with presskey, there will be the same effect - you need to test it).
PS: Somehow I watched Webvisor on a site with a placeholder. The person could not enter his name, he constantly pressed backspace, trying to erase it :)

I
Ilya Korablev, 2015-01-29
@swipeshot

<center>Ваш placeholder</center>
Not?

I
IceJOKER, 2015-01-29
@IceJOKER

Does text-align: center;n't it work?

M
Murat Atila, 2015-01-29
@TheExplay

Alternatively, use label and center absolutely inside the input

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question