HTML在输入文本上放置固定文本 [英] Html Put a fixed text on an input text

查看:379
本文介绍了HTML在输入文本上放置固定文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将默认文本放入用户无法删除的html输入元素中(输入开始时固定的文本)。

How can i put a default text in an input html element which user can't delete (fixed text on start of the input).

第二件事是我想要的

推荐答案

如果只想使用输入元素来解决此问题,则可以使用内联svg背景。

If you want to fix this with only an input element you can use an inline svg background.

http:// codepen。 io / anon / pen / pJoBya

要在Internet Explorer中实现此功能,您需要encodeURIComponent SVG图像
> http://pressbin.com/tools/urlencode_urldecode/

To make this work in Internet Explorer you need encodeURIComponent the SVG image http://pressbin.com/tools/urlencode_urldecode/

input {
  background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="30"><text x="5" y="19" style="font: bold 16px Arial;">Age:</text></svg>') no-repeat;
  border: 1px solid #555;
  box-sizing: border-box;
  font: 16px "Arial";
  height: 30px;
  padding-left: 50px;
  width: 300px;
}

<input type="text" />

这篇关于HTML在输入文本上放置固定文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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