javascript - How to write text on image in html - Stack Overflow

Is it possible that we can write text on image using html or javascript.I have done thisCreated an em t

Is it possible that we can write text on image using html or javascript.

I have done this

Created an em tag and create spans inside it and now we can write any text in spans and adjust the position of em tag such that it appears over image. Set the z-index of em tag to be larger value then image. Then it appears that text is written over image.

But I want to provide option using which a visitor can edit the text. How i can do it ?

Code Sample:-

$("#em1").html("<p><span>Hi I am</span><br>
<span> Trying to </span><br><br>
<span> To write text</span></p>");


#em1{
    display: block;
    /*border: 1px solid black;*/
    position: absolute;
    top: 160px;
    right: 145px;
    z-index : 10;
}

I am using a background (blank-nothing written on it) image

Is it possible that we can write text on image using html or javascript.

I have done this

Created an em tag and create spans inside it and now we can write any text in spans and adjust the position of em tag such that it appears over image. Set the z-index of em tag to be larger value then image. Then it appears that text is written over image.

But I want to provide option using which a visitor can edit the text. How i can do it ?

Code Sample:-

$("#em1").html("<p><span>Hi I am</span><br>
<span> Trying to </span><br><br>
<span> To write text</span></p>");


#em1{
    display: block;
    /*border: 1px solid black;*/
    position: absolute;
    top: 160px;
    right: 145px;
    z-index : 10;
}

I am using a background (blank-nothing written on it) image

Share Improve this question edited Apr 26, 2012 at 12:38 Sachin Jain asked Apr 26, 2012 at 12:28 Sachin JainSachin Jain 21.9k34 gold badges110 silver badges176 bronze badges 6
  • Add some code youve tried? that way we can help better – Brad Fox Commented Apr 26, 2012 at 12:30
  • 1 Use the image as a background-image for a textarea. But do you mean in a way that the text actually bees part of the image?? – Mr Lister Commented Apr 26, 2012 at 12:31
  • 2 You can to do it with contenteditable. – user1150525 Commented Apr 26, 2012 at 12:32
  • Can you add image in background using CSS. – Riz Commented Apr 26, 2012 at 12:32
  • @MrLister, @ dev did you actuelle read the question? He just needs something like contenteditable. – user1150525 Commented Apr 26, 2012 at 12:33
 |  Show 1 more ment

3 Answers 3

Reset to default 4

Set the contenteditable attribute on the em element. You probably need to inform users about the edibility, as people don’t normally expect it, and there is nothing in the visual appearance that suggests it.

You can have a textarea

<textarea  class='abc' >Hello Boys</textarea>

with some css applied to it.

.abc{

background: url('http://www.bzfusion/skymaps/sky_englishspring.jpg') no-repeat; background-color:red; width:300px;
height:500px; }​

A good practice for this kind of feature is that drawing is done on server side. If you really need to draw on client, use HTML5 canvas.

If you will need to save that image, read this article: http://www.nihilogic.dk/labs/canvas2image/

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745515132a4630948.html

相关推荐

  • javascript - How to write text on image in html - Stack Overflow

    Is it possible that we can write text on image using html or javascript.I have done thisCreated an em t

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信