Skip to content

[CSS Gap Decorations] Consider using pseudo elements? #987

Closed
@spoike

Description

@spoike

Hi, did you consider controlling the gap decorations with pseudo elements? It would be a generic approach and is close to how ::after and ::before works, and it could work both for flexbox and grid. It would also let you do things like breadcrumb trails and borders with a graphic in them.

Here is a CSS sketch of a breadcrumb trail that lets you insert a character or image (with content) in the gap between breadcrumb items.

ol.breadcrumbs {
  display: flex;
  flex-direction: row;
  gap: 3ch;
}
ol.breadcrumbs::gap-main-axis {
  height: 1em;
  width: 1ch;
  content: ">";
}
ol.breadcrumbs > li {
  display: inline-flex;
}

<ol class="breadcrumbs"><li>One</li><li>Two</li></ol>
-> Would render "One > Two"

Here is a CSS sketch where you define a border with an image handle inside the gap.

.grid {
  display: grid;
  grid-template: auto / auto;
}
.grid::gap-col {
  display: flex;
  align-items: center;
  height: 50%;
  width: 1px;
  background-color: 
  content: url("column-gap-image.png");
}
.grid::gap-row {
  display: flex;
  align-items: center;
  width: 50%;
  height: 1px;
  background-color: black;
  content: url("row-gap-image.png");  
}

That's my two cents.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions