Results 1 to 5 of 5

Thread: Creating input text with background image in HTML

  1. #1
    Join Date
    Dec 2009
    Posts
    66

    Creating input text with background image in HTML

    Hi everyone ,
    I am a new HTML programmer with just one month of experience in html programming recently i started to create a form and controls like textbox submit buttons and checkboxes. While i was browsing through over the internet i noticed a search textbox with an image , isearched for that in my books an all other stuffs from which i am learning the html. can anyone tell me how can i insert an image in a text box using HTML

  2. #2
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Creating input text with background image in HTML

    if you want to create an input box with an image which we want to use as background you just have to put the following code in the head part of your HTML program

    HTML Code:
    <style type='text/css'>
    
    .inputbox1 {
    width: 150px;
    margin: 0 0 1em 0;
    border: 1px solid #444444;
    background:url('images/img1.gif') no-repeat right top;
    }
    
    .inputbox2 {
    width: 150px;
    margin: 0 0 1em 0;
    border: 1px solid #444444;
    background:url('images/img2.gif') no-repeat right top;
    }
    
    .inputbox3 {
    width: 150px;
    margin: 0 0 1em 0;
    border: 1px solid #444444;
    background:url('images/img3.gif') no-repeat right center;
    padding-right:20px;
    }
    
    .inputbox4 {
    width: 150px;
    margin: 0 0 1em 0;
    border: 1px solid #444444;
    background:url('images/img1.gif') no-repeat left center;
    padding-left:20px;
    }
    
    </style>

    HTML Code:
    After that you just have to input the following codes into the body of your html program
    
    <form id="loginForm" name="Form1" method="post">
    <input class="inputbox1" type="text" size="15" name="uname" />
    <input class="inputbox2" type="password" size="15" value="" name="pwd" />
    <input class="inputbox3" type="text" size="15" value="" name="src" />
    <input class="inputbox4" type="text" size="15" value="" name="star" />
    </form>
    Last edited by Measurer; 23-12-2009 at 09:52 PM.

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Creating input text with background image in HTML

    you can create an input box with an image First, Download the image into your system after that you can simply create it by adding a background image to the the input tag and a left padding so that the text doesn't overlap the background image.

    This is a small segment of the CSS:

    .searchBox1{
    background-image:url('images/image_you_wantto_add.gif');
    background-repeat:no-repeat;
    padding-left:30px;

  4. #4
    Join Date
    May 2008
    Posts
    2,297

    Re: Creating input text with background image in HTML

    Try to apply a simple logic, to do it Just use background-image for the "form" attribute and after that add padding=12, text-align:center Else just put the form inside a DIV tag with the background-image. I use this all the time, it looks great with the perfect image. You will have to use Background image on the corresponding textfield on which you want to add the image. Its as simple as that.

  5. #5
    Join Date
    Dec 2009
    Posts
    66

    Re: Creating input text with background image in HTML

    Firstly above all i would like to thanks all of you for giving me all your valuable replies since because of these replies i had learned a lot . I got the logic of inserting an image in an input text. Although i could not understand what Zecho wanted to tell but the above solutions worked for me . anyway guys thanks again for helping me in this matter.

Similar Threads

  1. Creating continuous image marquee in HTML
    By Camillee in forum Software Development
    Replies: 5
    Last Post: 06-01-2010, 10:12 PM
  2. How to have a transparent background image for html pages
    By GlassFish in forum Software Development
    Replies: 3
    Last Post: 03-11-2009, 03:54 PM
  3. How to put text beside an image in HTML
    By KADRI in forum Software Development
    Replies: 3
    Last Post: 01-10-2009, 09:35 PM
  4. How to set html text background
    By Broot in forum Software Development
    Replies: 3
    Last Post: 29-07-2009, 03:16 PM
  5. Html need to know about text wrap padding around an image
    By ComPaCt in forum Software Development
    Replies: 2
    Last Post: 09-07-2009, 08:30 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,714,057,214.68288 seconds with 17 queries