cdog5000 Posted February 23, 2009 Share Posted February 23, 2009 OK, So i have this image (attached) how do i put a text field in the middle of it? [attachment deleted by admin] Quote Link to comment https://forums.phpfreaks.com/topic/146438-textfield-in-image/ Share on other sites More sharing options...
noober Posted February 23, 2009 Share Posted February 23, 2009 Make the image appear as the background image in your text field. Create the text field and give it a class name. Then in css, assign the given image as the background image. You might need a fix for IE6 though. Quote Link to comment https://forums.phpfreaks.com/topic/146438-textfield-in-image/#findComment-769002 Share on other sites More sharing options...
nauir Posted February 23, 2009 Share Posted February 23, 2009 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! Quote Link to comment https://forums.phpfreaks.com/topic/146438-textfield-in-image/#findComment-769438 Share on other sites More sharing options...
haku Posted February 24, 2009 Share Posted February 24, 2009 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; } Quote Link to comment https://forums.phpfreaks.com/topic/146438-textfield-in-image/#findComment-769776 Share on other sites More sharing options...
nauir Posted March 15, 2009 Share Posted March 15, 2009 haha whoops! I was doing Javascript all day! My bad. Quote Link to comment https://forums.phpfreaks.com/topic/146438-textfield-in-image/#findComment-785329 Share on other sites More sharing options...
TheFilmGod Posted March 16, 2009 Share Posted March 16, 2009 I personally prefer to put all padding declaration into one statement: padding-left:10px; padding-right:11px; padding-top:10px; padding: 10px 11px 0 10px; Quote Link to comment https://forums.phpfreaks.com/topic/146438-textfield-in-image/#findComment-786193 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.