首页 > 开发 > CSS > 正文

图片上添加文字的两种常用方式

2024-07-11 08:35:12
字体:
来源:转载
供稿:网友

1.常用的方式是:将一张图片设置为背景,然后在里面加文字,你加入的图片代码是:


<img src=”img.jpg” width=’100px” height=”50px”>

改为


<div style=”background:url(‘img.jpg’) no-repeat;width:100px;height:50px”>添加文字</div>

2.一种是:加<span>标签,设置css样式,你加入的代码是:


<div style=”position: relative; width: 170px; height: 89px;”>
<img src=”图片地址” width=”170″ height=”89″ alt=””>
<span style=”position: absolute; top: 0; left: 0;”>添加文字…添加文字…添加文字…</span>
</div>

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表