Reputation: 311
So i currently have the following bit of code:
Trouble I am having is the value I type overlaps the percentage sign. Im not sure how to go about adding some padding or alignment to prevent the overlap.
Any ideas?
.percentBlock {
width: 1500px;
}
.percentageSign {
position: relative;
right:20px;
}
<span class="percentBlock">
<input type="number" max="100" accuracy="2" min="0" style="text-align:right;">
<span class="percentageSign">%</span></span>
Upvotes: 2
Views: 943
Reputation: 8409
Take a look at this also
* {
box-sizing:border-box;
-webkit-box-sizing:border-box;
-ms-box-sizing:border-box;
-moz-box-sizing:border-box;
}
.percentBlock {
width: 200px;
float:left;
position:relative;
}
.percentageSign {
position: absolute;
right: 30px;
top:1px;
}
.percentBlock input {
padding-left:70.5%;
position:relative;
width:100%;
}
<span class="percentBlock">
<input type="number" max="100" accuracy="2" min="0">
<span class="percentageSign">%</span></span>
Upvotes: 1
Reputation: 258
.percentBlock {
width: 1500px;
}
.percentBlock input {
text-align:left;
width:55px;
}
.percentageSign {
position: relative;
right:35px;
}
<span class="percentBlock">
<input type="number" max="100" accuracy="2" min="0">
<span class="percentageSign">%</span></span>
I think this is what you are looking for.
Upvotes: 0
Reputation: 43574
You can use the following solution, so the %
is placed after the number controls:
.percentBlock {
width: 1500px;
}
.percentBlock input[type=number] {
padding-right:20px;
}
.percentageSign {
position: relative;
right:20px;
}
<span class="percentBlock">
<input type="number" max="100" accuracy="2" min="0" style="text-align:right;">
<span class="percentageSign">%</span>
</span>
Upvotes: 5