It is assumed that when we apply a background image to an input field that it is fixed. This is the case when short amounts of text is inputed, but once you type more than the length of the field in Internet Explorer, the background starts to move along with the text. Unfortunately, a simple background-attachment: fixed does not fix this problem.
Here is an example of what happens:
A work around which I stumbled upon is to wrap the input field in a DIV and apply the background to this, whilst making the input field’s background transparent. Your code should look like this:
#input_wrapper {
width: 180px;
height: 26px;
background: url('input_bg.png') no-repeat top left;
}
input.search {
width: 156px;
height: 16px;
background: transparent;
border: 0;
padding: 5px 12px;
margin: 0;
}
This is tested in Internet Explorer 6+ and Firefox.
Currently rated 4.5 by 2 people
- Currently 4.5/5 Stars.
- 1
- 2
- 3
- 4
- 5