【发布时间】:2020-05-12 23:22:45
【问题描述】:
我有这些使用 grid-css 构建的卡片问题是我需要使屏幕截图中突出显示的卡片部分可点击,包裹(除了“单独”之外,所有内容都应该是可点击的)。当我尝试这样做时,它完全破坏了我的布局。 [![在此处输入图像描述][1]][1] 我是 css-grid 的新手,将不胜感激。
<div class="outer">
<div class="wrapper">
<div class="color"></div>
<div class="row">Row 1</div>
<div class="info bottom-row">
<div class="info-inner">
<span> Info</span> <span> Separate</span>
</div>
</div>
<div class="cell bottom-row">Cell 1</div>
<div class="cell bottom-row">Cell 2</div>
<div class="cell bottom-row">Cell 3</div>
</div>
<div class="wrapper">
<div class="color bottom-row"></div>
<div class="row">Row 1</div>
<div class="info bottom-row">
<div class="info-inner">
<span> Info</span> <span> Separate</span>
</div>
</div>
<div class="cell bottom-row">Cell 1</div>
<div class="cell bottom-row">Cell 2</div>
<div class="cell bottom-row">Cell 3</div>
</div>
</div>
.outer {
display: grid;
grid-template-columns: 5px repeat(3, auto) auto;
border-radius: 4px;
overflow: hidden;
border: 1px solid #eee;
}
.color {
grid-row-start: span 2;
background: purple !important;
}
.row {
padding: 1rem;
grid-column: 2/-2;
}
.info {
padding: 1rem 0;
grid-row-start: span 2;
display: flex;
}
.info-inner {
padding: 1rem;
border-left: 1px solid #eee;
}
.cell {
padding: 1rem;
}
.bottom-row {
border-bottom: 1px solid #eee;
}
.wrapper {
display: contents;
cursor: pointer;
}
.wrapper:last-child > * {
border-bottom: 0;
}
【问题讨论】: