英文:
HTML / CSS: Borders between columns
问题
我正在尝试使用Flexbox创建列布局,并希望在每个列之间有垂直的全高度边框。
这是我试图创建的效果 — BORDERS IMAGE
.testing {
display: flex;
flex-direction: row;
padding: 10%;
flex-wrap: wrap;
background-color: red;
height: 20%;
}
.testing > div {
width: 100px;
background-color: green;
margin: 10px;
padding: 10px;
text-align: center;
}
<div class="testing">
<div class="col">
00
</div>
<!-- 其他列 -->
</div>
我在某处看到最好使用Flexbox来实现这个效果,但我找不到与边框相关的属性?
英文:
I'm trying to create a column layout using Flexbox and would like there to be vertical, full-height borders in between each of the columns.
Here is the kind of thing I'm trying to produce — BORDERS IMAGE
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.testing {
display: flex;
flex-direction: row;
padding: 10%;
flex-wrap: wrap;
background-color: red;
height: 20%;
}
.testing > div {
width: 100px;
background-color: green;
margin: 10px;
padding: 10px;
text-align: center;
}
<!-- language: lang-html -->
<div class="testing">
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
</div>
<!-- end snippet -->
I read somewhere that it is best to use Flexbox to achieve this, yet i cant find any properties relating to borders?
答案1
得分: 0
玩一下gap
属性。
.testing {
display: flex;
flex-direction: row;
padding: 10%;
flex-wrap: wrap;
/* 背景颜色: 红色; */
height: 20%;
gap: 1px;
}
.testing > div {
width: 100px;
背景颜色: 绿色;
/* 外边距: 10px; */
padding: 10px;
文本对齐: 居中;
边框: 10px 实线 红色;
}
<div class="testing">
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
</div>
英文:
Play around with the gap
property.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-css -->
.testing {
display: flex;
flex-direction: row;
padding: 10%;
flex-wrap: wrap;
/* background-color: red; */
height: 20%;
gap: 1px;
}
.testing > div {
width: 100px;
background-color: green;
/* margin: 10px; */
padding: 10px;
text-align: center;
border: 10px solid red;
}
<!-- language: lang-html -->
<div class="testing">
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
<div class="col">
00
</div>
</div>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论