【发布时间】:2018-06-14 02:10:27
【问题描述】:
我正在尝试在图片前面添加评级文字。我通过z-index和position: absolute做到了这一点。但是,此文本应始终位于照片的该位置,现在它具有静态位置。文本是标题的等级编号。而且应该是这样的。我该如何做到这一点?
.rating{
color: white;
font-family: 'Abril Fatface', cursive;
font-size: 3.5rem;
z-index: 1;
margin-top: 5rem;
}
.rating-lant{
position: absolute;
right: 63rem;
top: 37rem;
}
.img-title-activity{
margin-left: 10rem;
z-index: 0;
}
<div class="container">
<p class="rating rating-lant">7.5</p>
<img src="./assets/img/Lantaarnopsteker-title@288x.png" alt="Lantaarnopsteker" width="584" height="264" class="img-title-activity">
</div>
【问题讨论】:
-
尝试将
position:relative添加到容器中,这将使评级根据容器占据位置 -
完成了这项工作,非常感谢!
标签: html css responsive absolute