Is there any way to place an image inside of a text field with HTML/CSS/JS, not using the image as a background? The im开发者_JAVA百科age needs to be clickable and positioned on the right of the field, too. Thanks.
Other than having the image floating over the text field via positioning and z-index and adding padding to the text field to prevent the content to get underneath the image, I can't think of any other way to achieve that.
Do you mean a small image inside of a form text field? Generally you can use the placeholder attribute but the only attribute value placeholder can have is text. If/when they add in additional values for the attribute (plus not all browsers support placeholders) then you would be able to specify the opacity, float, etc in the css stylesheet.
I think it would be better if you put a small icon to the right of the text field, it would more easily and recognizably accomplish the same thing.
While you could use a z-index I think that would be a lot more work than it would be worth, kwim?
EDIT TO ADD: This was bugging me so I did a little poking around and found this link: http://www.jankoatwarpspeed.com/post/2008/11/26/Make-image-buttons-a-part-of-input-fields.aspx
I don't know how user friendly this is to you, but perhaps it's worth taking a look at!
精彩评论