1

I'm having trouble to move text inside input. If i add margins or paddings it moves or scales the input. I want to move "Username" 10px away from left side.

.log_inp input[type="username"] {
  top: 80px;
  height: 28px;
  width: 234px;
  border: solid 1px #e4e4e4;
  font-family: OpenSans-Italic;
  color: #9a9a9a;
  font-size: 13px;
}
input {
  padding: 0px;
}
<div class="log_inp">
  <form action="#">
    <input type="username" name="Username" placeholder="Vārds...">
    <br>
    <input type="password" name="Password" placeholder="Parole...">
    <br>
    <input type="submit" value="Ienākt">
  </form>
</div>

enter image description here

j08691
  • 204,283
  • 31
  • 260
  • 272
Berisko
  • 545
  • 2
  • 8
  • 21
  • You mean you want to push the placeholder text over to the right? – j08691 Apr 01 '16 at 16:29
  • Possible duplicate of [HTML5 placeholder css padding](http://stackoverflow.com/questions/4919680/html5-placeholder-css-padding) – Katrina Apr 01 '16 at 16:31

5 Answers5

1

If you want to change the padding and not have it influence the total size of the input, set box-sizing to border-box.

In the following example, the two inputs are the same size, but I have given the username one a left padding.

.log_inp input {
  top: 80px;
  height: 28px;
  width: 234px;
  border: solid 1px #e4e4e4;
  font-family: OpenSans-Italic;
  color: #9a9a9a;
  font-size: 13px;
  padding: 0px;
  box-sizing: border-box;
}
input[type="username"] {
   padding-left:10px;
}
<div class="log_inp">
  <form action="#">
    <input type="username" name="Username" placeholder="Vārds...">
    <br>
    <input type="password" name="Password" placeholder="Parole...">
    <br>
    <input type="submit" value="Ienākt">
  </form>
</div>
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
1

If you want to only move the placeholders over, use vendor prefix CSS properties:

::-webkit-input-placeholder {
   padding-left: 10px;
}
::-moz-placeholder { 
   padding-left: 10px;
}
:-ms-input-placeholder {  
   padding-left: 10px;
}
<div class="log_inp">
  <form action="#">
    <input type="username" name="Username" placeholder="Vārds...">
    <br>
    <input type="password" name="Password" placeholder="Parole...">
    <br>
    <input type="submit" value="Ienākt">
  </form>
</div>
Mr Lister
  • 45,515
  • 15
  • 108
  • 150
j08691
  • 204,283
  • 31
  • 260
  • 272
0

.log_inp input[type="username"] {
 
  height: 28px;
  width: 234px;
  border: solid 1px #e4e4e4;
  font-family: OpenSans-Italic;
  color: #9a9a9a;
  font-size: 13px;
 padding-left:10px;
}
input {
  padding: 0px;
}
<div class="log_inp">
  <form action="#">
    <input type="username" name="Username" placeholder="Vārds...">
    <br>
    <input type="password" name="Password" placeholder="Parole...">
    <br>
    <input type="submit" value="Ienākt">
  </form>
</div>
ratiorick
  • 572
  • 3
  • 7
0

With accepted answer cursor position of input is not modified.

You can move placeholder text of your input along with its cursor position via

input {
  text-indent: 10px;
}

https://www.w3schools.com/csSref/pr_text_text-indent.asp

midzer
  • 347
  • 4
  • 4
-1

Check it out it might be helps u

input{
    text-align:center;
}
Balvant Ahir
  • 610
  • 1
  • 9
  • 16