css - ngFor 中项目之间的水平虚线
问题描述
我正在使用 ngFor 显示由水平虚线分隔的项目列表,如下所示:
<div *ngFor="let comment of comments;let lastItem = last;">
<div class="comment-box">
<div class="comment-author">{{comment.createdBy}}</div>
<div class="creation-date">{{comment.createdOn}}</div>
<div class="comment-text">{{comment.text}}</div>
</div>
<div class="dashed-line-box" *ngIf="!lastItem">
<hr class="new1">
</div>
</div>
.dashed-line-box {
position: relative;
background-color: #ffffff;
width: 320px;
height: 16px;
border-style: solid;// to outline the container box
border-width: thin;
}
hr.new1 {
position: absolute;
margin-top: 8px;
border-top: 1px dashed;
}
我可以看到每个虚线框条目的矩形,但它们不像我期望的那样包含水平线。
我在这里想念什么?
解决方案
我想你想要一个虚线边框样式<hr>
hr.new1 {
position: absolute;
margin-top: 8px;
border-top: 1px dashed blue;
width: 100%;
}
或者,如果您想在外部 div 上使用虚线边框,请尝试以下代码
.dashed-line-box {
position: relative;
background-color: #ffffff;
width: 320px;
height: 16px;
border-bottom: 1px dashed green;
}
推荐阅读
- javascript - JavaScript - 如何在显示为正方形/矩阵的元素的线性数组中按键查找元素的 x,y 位置?
- python - 将数据帧的部分行从数字转换为日期时间,但得到奇怪的数字
- android - 从一部手机到另一部手机的远距离Android屏幕共享
- java - 即使导入了类也找不到符号
- php - 无法将 WordPress 备份从实时安装到本地
- javascript - Firefox 没有在 Service Worker 中为推送消息打开窗口
- sql - 如果列不包含另一列的 ID,则创建行
- java - 我怎样才能得到正确的平均分和成绩?
- ios - 辅助功能将焦点设置到导航栏标题项
- progressive-web-apps - Android 上的 PWA:用时钟隐藏顶部栏?