Cascading Style Sheets (CSS)

Create a text field with image background

This little css code will create a text field with an image background.
All we need is an image and a little css code.
In this example we use the magnifying glass image.
The text field is created by adding the background image and left.

This input box is simply created by adding a background image to the input tag and a left padding so that the text doesn't overlap the background image.




The ccs code:
.searchBox{
  background-image:url('images/magnifying-glass.gif');
  background-repeat:no-repeat;
  padding-left:20px;
}


The text field code:
<input type="text" name="search" class="searchBox">

This will create a text field like the image below.



For a working example of this, click on "CSS Tutorial Search" (left menu).


User Comments: 1

 It doesn't work in IE6

It doesn't work in IE6. When you type very long string, that is longer that input width, then the zoom icon disapear...

Add your comments

Your Name*:
Your Email:
Site URL:
Site Name:
Comemt Title*:
Your Comment*:
Key Phrase*:
1nK
Your IP Address: 38.103.63.62
 

ScandicWeb is own by Scandic Systems LTD [UK] Company No. 5984000. All other trademarks and copyrights are the property of their respective holders.

[Home [Site Map [Privacy Statement [Site Feedback] [About ScandicWeb]


[ColdFusion [Flash [Search Engine Optimization [Graphics [Cascading Style Sheets (CSS) [JavaScript (JS) [Software]

Partner sites: ScandicSoft


Server time: 19. November 2008 Wednesday