是否可以在表单输入中粗体显示部分占位符文本(即默认值)? [英] Is it possible to bold only partial placeholder text (i.e. default value) within a form input?

查看:124
本文介绍了是否可以在表单输入中粗体显示部分占位符文本(即默认值)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能重复:

$ b例如,如果我们有一个表单输入,其占位符文本是探索世界,例如paris,france,可以是CSS,jQuery,HTML5或任何其他方法可能允许我们在表单输入中将部分文本粗体显示为:探索世界,例如paris,france。

For example, if we have a form input whose placeholder text is "explore the world, e.g. paris, france", can CSS, jQuery, HTML5, or any other method possible allow us to bold only partial text within the form input to render as: "explore the world, e.g. paris, france".

我只知道允许我们将整个占位符文字加粗的方法,完全呈现为探索世界,例如巴黎,法国

I am only aware of methods that allow us to bold the entire placeholder text, rendering entirely as "explore the world, e.g. paris, france".

通过说明,这里是这个问题的目标:

By illustration, here is the goal of this question:

推荐答案

没有办法使用标准输入[type = text]你可以尝试覆盖HTML,但是一些浏览器处理输入字段作为控件,并且不会像正常的html dom元素一样。

There is no way to accomplish this with a standard input[type=text] field. You can try to overlay HTML but some browsers handle input fields as controls and will not behave as regular html dom elements.

我使用的方法是这样的: / p>

The approach I would use is something like this:

<html>
<head>
  <style type="text/css">

    div.input { border:1px solid #aaa; width:300px; }

  </style>

</head>
<body>

    <div contenteditable="true" class="input"><strong>explore the world,</strong> e.g. paris, france</div>

</body>
</html>

希望这有帮助。祝你好运。

Hope this helps. Good luck.

这篇关于是否可以在表单输入中粗体显示部分占位符文本(即默认值)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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