4

The field below retrieves hourly pay rate from user input. How can I display a "$" sign inside (or before) the input field where the user types in the hourly pay rate?

<tr>
<td>Hourly Pay Rate</td>
<td><input type = "number" name = "HPR" min="0" step="0.01"  required></td>
</tr>
Programmer
  • 1,266
  • 5
  • 23
  • 44

4 Answers4

13

.dollar{
 display:inline-block;
 position: relative;
 }
.dollar input{
 padding-left:15px;
 }
.dollar:before {
 position: absolute;
    content:"$";
    left:5px;
 top:2px;
  }
<div class="dollar"><input type="number"></div>
CerebralFart
  • 3,336
  • 5
  • 26
  • 29
Cris
  • 2,824
  • 24
  • 23
1
.dollar::before {
    content: "$";
    padding: 0 5px;
    text-align: center;
}
<div class="dollar">
<input type ="text">
</div>
0

Not sure what you are asking for :

first one will just put a "$"sign before the input type

<tr>
<td>Hourly Pay Rate</td>
<td>$<input type = "number" name = "HPR" min="0" step="0.01"  required></td>
</tr>

second one will put a "$" inside the input type and will disappear once user start typing.

<tr>
<td>Hourly Pay Rate</td>
<td><input type = "number" placeholder="$" name = "HPR" min="0" step="0.01"  required></td>
</tr>
ellaRT
  • 1,346
  • 2
  • 16
  • 39
0

Before input box you can try this:

<td>Hourly Pay Rate($):</td> <td><input type = "number" name = "HPR" min="0" step="0.01" required></td>

Bijal
  • 132
  • 1
  • 8