Jump to content

TextField in image


cdog5000

Recommended Posts

Here is the code you should use:

<script>
.class1{
background:url('INSERT URL HERE');
}
</script>
<input type=text class='class1'>TYPE HERE</input>

 

That will put the input in the bg. That is the only way to really do this. You can also do it with a table and center the input to have it centered inside the input.

 

Here is the table example:

<script>
.class1{
background:url('INSERT URL HERE');
}
</script>
<table width=200 height=200 border=0>
<tr><td  class='class1'>
<input type=text>TYPE HERE</input>
</td></tr>
</table>

 

I hope this helps!

Link to comment
Share on other sites

It's good that you helped the guy, thanks for contributing to the site. There were a few problems with your code though. This:

 

<script>
.class1{
background:url('INSERT URL HERE');
}
</script>

 

should be wrapped in style tags, like this:

 

<style type="text/css">
.class1{
background:url('INSERT URL HERE');
}
</style>

 

Script tags are for scripting languages. CSS is a markup language, which is why it's style tags.

 

Also, there is no need to use tables for this at all.

CSS:

#target
{
  background:url('INSERT URL HERE') no-repeat top left;
  height: __px; // enter the height of the image in pixels here
  width: __px; // enter the width of the image in pixels here
}

HTML:

<input type="text" id="target" />

 

You will also need some padding in order to get the text in the right spot. Here is the CSS you can start with - you will need to check it in various browsers, as I only checked it in FF. But it will work with the background image attached to the original post:

 

#target
{
  background:transparent url(searchbox.png) no-repeat scroll left top;
  font-size:20px;
  height:35px;
  padding-left:10px;
  padding-right:11px;
  padding-top:10px;
  width:128px;
}

Link to comment
Share on other sites

  • 3 weeks later...
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.