【发布时间】:2019-12-18 22:08:55
【问题描述】:
我在使用网格系统时遇到问题。虽然我尝试做一些看板式的 d&d 系统。
问题如下图所示。 如箭头所示,每张卡片都应放置在某个位置。 由于第二列是“空的”-> 里面还没有卡片,所以它只应用了填充。
以前它运行良好,因为所有内容都在同一个列中,并且由于标题(颜色指示的卡片)在所述列中,因此它具有正确的宽度。
但是我需要分离标题,因为我想实现一些粘性行为 -> 当我们使用垂直滚动时,标题应该保持在顶部。
模板如下:
<div #autoscroll
class="col wholeTable">
<div class="row pipe-header">
<ng-container *ngFor="let stage of cardList; let i = index">
<div class="col">
<ng-container *ngIf="pipelineConfig.headerTemplate; else noHeaderForYou">
<ng-container
*ngTemplateOutlet="pipelineConfig.headerTemplate; context : {$implicit: headerList[i], count: cardList[i].items.length}">
</ng-container>
</ng-container>
<ng-template #noHeaderForYou>
<!-- Displaying some useful info even if no custom template is present-->
<dt-pipeline-header [label]="headerList[i].elementLabel"
[count]="cardList[i].items.length">
</dt-pipeline-header>
</ng-template>
</div>
</ng-container>
</div>
<div class="row stage">
<ng-container *ngFor="let stage of cardList">
<div class="col"
dragula="cardList"
[(dragulaModel)]="stage.items"
attr.id="{{stage.key}}">
<ng-container *ngFor="let item of stage.items">
<div class="card"
[ngClass]="{
'dragabble' : pipelineConfig.permissionChecker(item),
'nodrag': !pipelineConfig.permissionChecker(item)
}">
<div class="card-body">
<ng-container *ngIf="!pipelineConfig.permissionChecker(item)">
<span class="disabled-indicator"><i class="fas fa-ban"></i></span>
</ng-container>
<ng-container
*ngTemplateOutlet="pipelineConfig.bodyTemplate; context: {$implicit: item, showColumns: showContent}">
</ng-container>
</div>
</div>
</ng-container>
</div>
</ng-container>
</div>
</div>
component.css:
@media only screen and (max-width: 600px) {
.wholeTable {
display: block;
}
}
.stage {
word-break: break-word;
min-height: 100%;
flex-wrap: nowrap;
.col {
min-width: min-content;
}
}
.card.dragabble:hover {
cursor: grab;
}
.card.dragabble, .card.nodrag {
margin: 1rem 0rem;
}
.pipe-head-divider {
margin-bottom: 0;
}
.disabled-indicator{
display: flex;
float: right;
position: relative;
top: -0.5rem;
right: -0.5rem;
}
.wholeTable {
overflow-x: scroll;
overflow-y: hidden;
flex-wrap: nowrap;
}
.pipe-header {
flex-wrap: nowrap;
}
【问题讨论】:
-
如果没有内容,也许您可以增强您的模板,将
empty类添加到列中,然后在此列上使用display:none -
@yunzen 我想你误会了我需要那个专栏。因为它是可拖动卡片的容器。而且由于它没有宽度,所以整个东西都关闭了。
标签: html css angular bootstrap-4 css-grid