0

I want to implement a search button inside the search box, and i find it useful:Search button inside the search box like Bing

but when i place code into my site, it didn't show the way expected,what's wrong?

this is the code

HTML

<input type="text" id="q" />
<input type="button" id="b" value="Search" />

CSS

#q, #b { 
   margin: 0 
}
#q { 
   padding 5px; 
   font-size: 2em; 
   line-height: 30px 
}
#b { 
   /* image replacement */
   text-indent: -99999px; 
   width: 30px; 
   height: 30px; 
   display: block;
   background: gray url(button.png) 0 0 no-repeat;
}

code

Community
  • 1
  • 1
user2793559
  • 103
  • 1
  • 7

2 Answers2

1

Try This

#q, #b { 
   margin: 0 
   display:inline-block;
   float:left;
}
#q { 
   padding 5px; 
   font-size: 2em; 
   line-height: 30px; 
   border:none;
}
#b { 
   /* image replacement */
    margin-top:8px;
   width: 30px; 
   height: 30px; 
   background: gray url(button.png) 0 0 no-repeat;
}
.border {
   border:#ccc solid 1px; 
   width:390px;
}
.clear {
   clear:both;
}

<div class="border">
<input type="text" id="q" />
<input type="button" id="b" value="Search" />
    <div class="clear"></div>
</div> 

Check this out

Eugine Joseph
  • 1,552
  • 3
  • 18
  • 40
1

look at this:demo

html:

<div>
<input type="text" id="q" />
<input type="button" id="b" value="Search" />
</div>

CSS:

#q, #b { 
   margin: 0 
}
#q { 
   padding 5px; 
   font-size: 2em; 
   padding-left:50px;
   line-height: 30px 
}
#b { 
   /* image replacement */
   text-indent: -99999px; 
   width: 30px; 
   height: 30px; 
   display: block;
    position:absolute;
    top:4px;
    left:4px;
   background: gray url(button.png) 0 0 no-repeat;

   /* placing next to input using float or absolute positioning omitted ... */
}
div{
    position:relative;
}
Mohsen Safari
  • 6,669
  • 5
  • 42
  • 58