Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/91.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 输入标记中的多种字体颜色_Javascript_Html_Css - Fatal编程技术网

Javascript 输入标记中的多种字体颜色

Javascript 输入标记中的多种字体颜色,javascript,html,css,Javascript,Html,Css,我很好奇谷歌的即时搜索功能是如何在一个input[type=text]元素中保持两种不同的字体颜色的。黑色表示用户输入,灰色表示建议。谢谢它们只是在同一位置叠加另一个。启动Firebug、IE开发工具或其他工具,使用id='grey'查找 <div style="position: relative; background-image: none; background-attachment: scroll; background-repeat: repeat; background-po

我很好奇谷歌的即时搜索功能是如何在一个
input[type=text]
元素中保持两种不同的字体颜色的。黑色表示用户输入,灰色表示建议。谢谢

它们只是在同一位置叠加另一个
。启动Firebug、IE开发工具或其他工具,使用
id='grey'
查找

<div style="position: relative; background-image: none; background-attachment: scroll; background-repeat: repeat; background-position-x: 0%; background-position-y: 0%; background-color: transparent;">
  <div class="lst" id="grey" style="padding-left: 7px; white-space: nowrap;">
    Text - hello world
  <div class="lst" id="misspell"/>
<div class="lst" style="left: -9000px; top: -900px; width: auto; overflow: hidden; position: absolute; max-width: 3000px;">
  Text - hello w
<input name="q" title="Search" class="lst" type="text" maxLength="2048" autocomplete="off" init="true" value="hello w"/>

文本-你好,世界
文本-你好w

只需添加:请注意,您不能将光标标记/放置在搜索框中的文本中,因为您单击/标记的不是实际的输入框,而是div覆盖