在文本框中插入图像. [英] To insert image in the textbox.

查看:96
本文介绍了在文本框中插入图像.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想知道是否可以在文本框中显示图像吗?
如果是,那么如何使用javascript来实现呢?

谢谢!
Archana

Hi,

I want to know if it is possible to display an image in the textbox?
If yes then how to implement it in using javascript?

Thanks!
Archana

推荐答案

您可以为此使用css.设置背景图像.
You can use css for this. Set a background-image.
<input type="text" style="background-image: url(/Content/Icons/16/address_book.png);"/>



如果要在左侧显示小图像(例如搜索框的搜索图标),请添加不重复和一些填充以使文本位于图像旁边. (在此示例中,我使用了16x16px的图像)



If you want a small image at the left side (like a search icon for a search box) then add a no-repeat and some padding to make the text be placed beside the image. (in this example I''ve used a 16x16px image)

<input type="text" style="background-image: url(/Content/Icons/16/address_book.png); background-repeat: no-repeat;  padding-left: 16px;"/>



现在,您将拥有一个带有背景图标的漂亮文本框,并且该文本不会放置在该图标上.



Now you will have a nice textbox with a background icon and the text will not be placed over the icon.


您好,
尝试访问以下链接:
http://www.dreamincode.net/forums/topic/31007-urgent -displaying-images-in-textbox/ [ http://stackoverflow.com/questions/5496372/displaying-image-in-text-box [ ^ ]
http://stackoverflow.com/questions/1712163/show-image-after-textbox [ ^ ]

让我知道是否有帮助.

--Amit
Hi,
Try visiting the links below:
http://www.dreamincode.net/forums/topic/31007-urgent-displaying-images-in-textbox/[^]
http://stackoverflow.com/questions/5496372/displaying-image-in-text-box[^]
http://stackoverflow.com/questions/1712163/show-image-after-textbox[^]

Let me know if it helps.

--Amit


这篇关于在文本框中插入图像.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆