b_d
b_d

Reputation: 787

Multiple font colors in an Input tag

I'm curious as to how Google's instant search feature maintains two separate font colors within a single input[type=text] element. Black for the user input and gray for the recommendations. Thanks

Upvotes: 4

Views: 5055

Answers (1)

Joey
Joey

Reputation: 354366

They simply overlay another <div> at the same location. Fire up Firebug, IE Dev Tools or whatever and look for the <div> with 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"/>

Upvotes: 5

Related Questions