How to display a a href
and a img src
inside a input box (text box). ex: i want to display this inside a text box ( <input id=link
)
<a href="http://www.mysite.com/link" target="_blank"><img src=开发者_StackOverflow"http://www.mysite.com/img.jpg" border="0" alt="mysite.com"></a>
thanks in advance.
Based on the comments, I would guess that you want an input field that has that HTML code as the default text. You must use character reference codes for quotes and less/greater than signs.
<input type="text" value="<a href="http://www.mysite.com/link" target="_blank"><img src="http://www.mysite.com/img.jpg" border="0" alt="mysite.com"></a>" />
(By the way, you mentioned "like in Photobucket" -- you can just look at the site's HTML to see how they do it.)
You have two options.
- Place the image as a background of the input, but this won't be clickable.
- Absolutely position the element over an input.
1:
.myInput { background:url(path/to/img.jpg) 5px 5px no-repeat; }
2:
HTML
<div class="inputContainer">
<input class="myInput" type="text" name="myInput" id="myInput" />
<a href="#" class="inputImg"><img src="#" /></a>
</div>
CSS
.inputContainer { position:relative; }
.myInput { padding-left:25px; /* This will move the text from under the image */ }
.inputImg { left:5px; position:absolute; top:5px; z-index:5; }
You'll need to play with the position and values depending on your input size, image size and general placement, but that should do what you want.
As comments mention, you can't literally put a link in an input
text box (although you could simulate one with JavaScript).
For the background image, use CSS background-image
.
精彩评论