如何在CSS网格间隙之间填充文本?

问题描述 投票:-1回答:1

我有以下HTML:

<div class="grid-container">
  <div class="grid-row-1">...</div>
  <div class="grid-row-2">...</div>
  ...
</div>

是否有一种方法可以在这些网格行之间自动填充---AND------OR---之类的文本?

html css css-grid
1个回答
3
投票
我不确定这是否优雅,但是否可以使用:

<style> .grid-container > .and::after{ content: "---AND---"; } .grid-container > .or::after{ content: "---OR---"; } </style> <div class="grid-container"> <div class="grid-row-1 and">...</div> <div class="grid-row-2 or">...</div> ... <div class="grid-row-100">...</div> </div>

或者您可以这样做:

<style> .grid-container > div::after{ content: "---AND---"; } .grid-container > div:last-child::after{ content: "" !important; } </style> <div class="grid-container"> <div class="grid-row-1">...</div> <div class="grid-row-2">...</div> ... <div class="grid-row-100">...</div> </div>

© www.soinside.com 2019 - 2024. All rights reserved.