I'm having fun getting my head around the new CSS Grid spec, but I'm running into trouble with borders.
Is it possible to collapse borders in a CSS Grid, or is there any way to style the gutter?
As you can see in the snippet below, the 10px
borders stack (20px
total) in-between blocks.
I understand this issue isn't unique to CSS Grids, but I'm hoping it'll allow for new solutions for creating a uniform 10px border between all boxes and on the outer edges.
My actual use-case is a calendar I'm making to practice working with Grids and React components. You can see the issue I'm running into here:
.
Since every month is different, I'll have a lot of different edge-cases to consider.
.container {
display: grid;
grid-template-columns: 120px 120px;
box-sizing: border-box;
}
.block {
width: 100px;
height: 100px;
background-color: lightgrey;
border: 10px solid palegreen;
}
.first {
grid-column: 2 / span 1;
}
<div class='container'>
<div class='block first'>1</div>
<div class='block'>2</div>
<div class='block'>3</div>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…