css图片上面显示文字

2022年6月7日11:37:17
<!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>

css图片上面显示文字
在图片上展示的文字需要用absolute绝对定位,定位在想展示的位置,它的父元素imgbox要有position定位,且不能为static值。

  • 作者:qq_43101834
  • 原文链接:https://blog.csdn.net/qq_43101834/article/details/113506363
    更新时间:2022年6月7日11:37:17 ,共 864 字。