css图片上加文字

第一种方法:
添加一个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>

比较推荐第一种

posted @ 2017-09-06 17:13  沉迷编程的程序员  阅读(690)  评论(0编辑  收藏  举报