html+css怎么在图片上添加文字

如题所述

html+css在图片上添加文字有两种方法如下:

1.添加一个DIV,采用绝对定位,图片所属DIV为基准

<div style="position:relative;width:100px;height:100px;">
<img src="" alt="" />
<div style="position:absolute;width:100px;height:100px;z-indent:2;left:0;top:0;">
文字
</div>
</div>

第二种方法:图片作为背景图片

<div style="background:url(abc.jpg) no-repeat left top;">
wenzi
</div>

背景图片现在有了,然后在上面写上你需要写的字就可以了。

温馨提示:答案为网友推荐,仅供参考
相似回答