4
我很好奇Google的即时搜索功能如何在单个input[type=text]
元素内保持两种独立的字体颜色。黑色表示用户输入,灰色表示建议。谢谢输入标记中的多种字体颜色
我很好奇Google的即时搜索功能如何在单个input[type=text]
元素内保持两种独立的字体颜色。黑色表示用户输入,灰色表示建议。谢谢输入标记中的多种字体颜色
他们只是覆盖另一个<div>
在同一地点。启动Firebug,IE开发工具或任何东西,并寻找与id='grey'
<div>
。
<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"/>
只要添加:请注意,您不能在搜索框中的文本中标记/放置光标 - 因为它不是您点击/标记的实际输入框,而是div覆盖图 – 2010-11-13 01:29:55