Reputation: 27125
I'm trying to overlay text on an <input type="text">
(for cross-browser placeholder
support). I've found that my positioning is always off by a couple of pixels, because of some kind of padding which can't be removed by setting padding: 0;
. The suggestions here and here do not solve the problem.
You can see this padding in the following screenshot from Chrome, as the white space between the blue highlight and the yellow border:
How can I a) remove this space; or b) measure it using Javascript?
Upvotes: 6
Views: 265
Reputation: 71939
If you replace the default borders with your own, the padding goes away (at least for me, on Chrome/Mac):
This is the CSS I used:
input {
padding: 0;
outline: none;
border: 1px solid red;
}
Upvotes: 2
Reputation: 180
You need to reset everything. So it is best recommended to use:
<style>
html, body {
margin: 0;
padding: 0;
}
</style>
Hope this helped.
Upvotes: -1