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覆盖