html - 将 div 放在不同宽度的图像中
问题描述
我试图在所有图像上放置一个始终位于相同位置(右下角)的 div。
我的问题是,如果图像占据 100% 的宽度,则 div 会居中:(
我怎样才能把这个 div 放在图像上,总是在右下角,即使我有不同宽度的图像?
.boxImage {
flex: 1 1 100%;
cursor: pointer;
position: absolute;
background-color: white;
background-position: 13px 13px;
background-repeat: no-repeat;
height: 50px;
width: 44%;
border-radius: 8px;
opacity: 1;
top: 91%;
left: 43%;
max-width: 250px;
}
<div class="d">
<div class="a">
<img class="img-fluid" src="https://i.ibb.co/mqnwwKB/Screenshot-72.jpg">
<!-- <img class="img-fluid Images" src="https://i.ibb.co/3p3D4h6/dmitry-bayer-276d-F1-RG67-Q-unsplash.jpg"> -->
<div class="row b">
<ul class="list-inline rating-list" *ngFor="let star of stars" style="display: inline-block">
<li (click)="countStar(star)" [ngClass]="{'selected': (star <= selectedValue)}">
<i class="fa fa-star"></i>
</li>
</ul>
</div>
</div>
</div>
解决方案
在您的 css 文件中添加以下类。这将使您的白框相对于图像的位置。
.abc{
position: relative;
display: inline-block;
}
.abc .boxImage{
position: absolute;
right: 5px;
bottom: 5px;
}
工作演示:链接
推荐阅读
- kivy - 如何从 python 中的文本文件中识别问题?
- amazon-web-services - QuickSight 仪表板未在 iframe 中呈现
- r - 如何使用 `%>%` 更改一列值?
- javascript - 带有 puppeteer 的外部样式表
- c# - 如何通过 C# 在 sharePoint 上创建新的“链接文档”?
- ios - Xcode 11 beta 5 中没有 iOS 13 模拟器
- gitlab - 如何使用 gitlab api v4 检索特殊分支的所有提交?
- javascript - 如何让 JavaScript 只为 DOM 的一部分运行
- java - 如何检查具体的顺序并重新排列一段文字?
- python - Python Regex 循环非捕获组