b_d*_*b_d 4 html javascript css
我很好奇Google的即时搜索功能如何在单个input[type=text]元素中维护两种不同的字体颜色。黑色代表用户输入,灰色代表建议。谢谢
它们只是<div>在同一位置覆盖另一个。观察Firebug,IE开发工具或什么,并寻找<div>有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"/>
Run Code Online (Sandbox Code Playgroud)