<!DOCTYPE html><html><head><meta charset="utf-8"><title></title><style type="text/css"> .main{ width: 300px; height: 300px; padding: 10px; background-color:#0087F1;} .imgbox1{ position: relative;} img{ width: 100%; height: 100%;} .tips{ position: absolute; color: white; font-size: 10px; right: 10px; bottom: 10px; padding: 1px 3px; border-radius: 2px; background-color: rgba(0, 0, 0, 0.7); z-index: 2;}</style></head><body><div class="main"><div class="imgbox1"><img src="https://gimg2.baidu.com/image_search/src=http%3A%2F%2Farticle.fd.zol-img.com.cn%2Ft_s640x2000%2Fg5%2FM00%2F03%2F0D%2FChMkJlawkneIQL3lAARnfQ9pCogAAIOSAPcT2AABGeV555.jpg&refer=http%3A%2F%2Farticle.fd.zol-img.com.cn&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1614742344&t=8fed9d197f990c15c4bd191a5726a379"><div class="tips">专栏</div></div></div></body></html>
在图片上展示的文字需要用absolute绝对定位,定位在想展示的位置,它的父元素imgbox要有position定位,且不能为static值。