如何在文本字段值中添加 img

发布于 2025-01-02 01:01:15 字数 172 浏览 2 评论 0原文

我想在文本字段的默认值内显示图片。这是我尝试过的,但它不起作用。

<input type="text" value="<img src="../images/left_arrow.gif" />Word" />

我尝试过逃避“但这不起作用

I wanna show a picture inside the default value of a text field. this is what I've tried but it doesn't work.

<input type="text" value="<img src="../images/left_arrow.gif" />Word" />

I've tried escaping the " but that doesn't work

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

淡莣 2025-01-09 01:01:15

您需要将图像作为元素的背景。

html

<input type="text" class="with-default" value="Word" />

css

input.with-default{
   background: url('../images/left_arrow.gif') 0 0 no-repeat;
}

或者,如果您对实际箭头外观很灵活,则可以使用 unicode 字符来显示箭头 ie ⇐

了解更多 unicode 箭头:http://www.alanwood.net/unicode/arrows。 html

演示: http://jsfiddle.net/6GyVM/

you need to put the image as the background of the element..

html

<input type="text" class="with-default" value="Word" />

css

input.with-default{
   background: url('../images/left_arrow.gif') 0 0 no-repeat;
}

Alternatively, if you are flexible about the actual arrow appearance, you could use a unicode char to display the arrow i.e. ⇐

for more unicode arrows: http://www.alanwood.net/unicode/arrows.html

demo: http://jsfiddle.net/6GyVM/

奢望 2025-01-09 01:01:15

为什么要在文本字段中添加图片?如果只是装饰,使用CSS背景图片。

Why do you want a picture inside a text field? If it's just a decoration, use CSS background image.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文