这是代码 如何在这个图片上添加文字呢???
第一种方法,定位把文字放在上面 第二种方法,div里面放文字 设置背景图片 第三种方法,画布画
设置背景的方式常见是直接在一个div元素上设置宽高,并且给个background-image;例如
<div style="background-image: url(https://img1.baidu.com/it/u=1492824562,364473720&fm=26&fmt=auto&gp=0.jpg);width: 200px;height: 100px;">
<text>1111</text>
</div>
除此之外,还可以通过浮动方法来设置背景,但这种方法不推荐
<div style="width: 200px;height: 100px;position: relative;">
<img src="https://img1.baidu.com/it/u=1492824562,364473720&fm=26&fmt=auto&gp=0.jpg"
style="width: 100%;height: 100%;" />
<text style="position: absolute;top: 0;left: 0;">1111</text>
</div>
img:before { content: "文字"; position: absolute; top: 2px; left: 37px; } 参考