Center HTML Input Text Field Placeholder

前端 未结 10 1722
半阙折子戏
半阙折子戏 2020-11-28 03:53

How can I centre the input field\'s placeholder\'s alignment in a html form?

I am using the following code, but it doesn\'t work:

CSS ->

inpu         


        
相关标签:
10条回答
  • 2020-11-28 04:33

    you can use also this way to write css for placeholder

    input::placeholder{
       text-align: center;
    }
    
    0 讨论(0)
  • 2020-11-28 04:37
    input{
       text-align:center;
    }
    

    is all you need.

    Working example in FF6. This method doesn't seem to be cross-browser compatible.

    Your previous CSS was attempting to center the text of an input element which had a class of "placeholder".

    0 讨论(0)
  • 2020-11-28 04:42

    You can try like this :

    input[placeholder] {
       text-align: center;
    }
    
    0 讨论(0)
  • 2020-11-28 04:46
    ::-webkit-input-placeholder {
     font-size: 14px;
     color: #d0cdfa;
     text-transform: uppercase;
     text-transform: uppercase;
     text-align: center;
     font-weight: bold;
    }
    :-moz-placeholder { 
     font-size:14px;
     color: #d0cdfa;
     text-transform: uppercase;
     text-align: center;
     font-weight: bold;
    }
    ::-moz-placeholder { 
     font-size: 14px;
     color: #d0cdfa; 
     text-transform: uppercase;
     text-align: center;
     font-weight: bold;
    } 
    :-ms-input-placeholder { 
     font-size: 14px; 
     color: #d0cdfa;
     text-transform: uppercase;
     text-align: center;
     font-weight: bold;
    }
    
    0 讨论(0)
  • 2020-11-28 04:47

    If you want to change only the placeholder style

    ::-webkit-input-placeholder {
       text-align: center;
    }
    
    :-moz-placeholder { /* Firefox 18- */
       text-align: center;  
    }
    
    ::-moz-placeholder {  /* Firefox 19+ */
       text-align: center;  
    }
    
    :-ms-input-placeholder {  
       text-align: center; 
    }
    
    0 讨论(0)
  • 2020-11-28 04:49

    You can make like this:

        <center>
        <form action="" method="POST">
        <input type="text" class="emailField" placeholder="support@socialpic.org" style="text-align: center" name="email" />
        <input type="submit" value="submit" />  
    </form>
        </center>
    

    Working CodePen here

    0 讨论(0)
提交回复
热议问题