我希望将一个文字放在背景图像的底部并留有一些垂直偏移量。
例如:
同样的方法,我们可以这样做:
但是这个图片甚至不会显示出来。
我该如何做到这一点?(不需要知道元素的高度)
到目前为止,我的解决方法是将填充(图像大小)和边距(偏移量)应用于具有“position: bottom center;”属性的元素。
例如:
同样的方法,我们可以这样做:
.img{
background-position: 5px center; /* top + 5px */
}
我尝试着:
.img{
background-position: -5px center; /* bottom - 5px ?? */
}
但是这个图片甚至不会显示出来。
我该如何做到这一点?(不需要知道元素的高度)
到目前为止,我的解决方法是将填充(图像大小)和边距(偏移量)应用于具有“position: bottom center;”属性的元素。