Maybe this is an easy question, but I have been searching it for a long time and no luck. I simply need to use an image as an input type=text, instead of using the white box like normal. I tried to use background-image, but then the white is still there, only it has a background image. I don't need the white box. How can I do that?
3 Answers
Like this:
HTML
<label for="test">Label here</label> <input type="text" name="test" id="test" placeholder="placeholder text" /> CSS
input[type=text] { background:url(http://placekitten.com/200/200) no-repeat 0 0; border:0 none; padding:4px 10px; color:#fff; } 2 Comments
ishwr
thanks! I just have to add the background color to transparent. thanks!
WreithKassan
+1 U was messing with the fiddle, and the issue was that you had 4px 4px at the end of the image url, which gave you a margin. By making it 0 0, Nick R made it fill the space.
Is this what you're after?
HTML
<div class="image">Text text text text text text text</div> CSS
.image { width:400px; height:200px; background-image:url(http://3.bp.blogspot.com/-HX2iaDPwkhs/T6IEBoiufuI/AAAAAAAAAyQ/dtC9Sr268_k/s1600/doodle-525-cloud.jpg); } 2 Comments
ishwr
unfortunately no. I need to use an image as an input text
SaturnsEye
What does that even mean? you can't just type on an image, you need create something to type over it.
If I understand you correctly, this may be a solution. Applying a background image to a text input field: fiddle
html:
<textarea rows="10" cols="10" class="input">default text</textarea> css:
.input { background-image: url(http://www.placehold.it/10x10); }
border:nonemakes the trick actually, what browser are you using to view it? or have you got an example of what you want? because maybe we are missing the point