如何创建一个包含2列的行,这些行变成2行,每行只使用CSS而不使用前端框架?我试着阅读CSS Grid,但这对我来说似乎太混乱了。如果有人可以简单地为我做,我将不胜感激。谢谢!
答案 0 :(得分:1)
尝试此代码,例如不需要引导程序
.row::after {
content: "";
clear: both;
display: table;
}
[class*="col-"] {
float: left;
padding: 15px;
border: 1px solid red;
}
.col-1 {width: 8.33%;}
.col-2 {width: 16.66%;}
.col-3 {width: 25%;}
.col-4 {width: 33.33%;}
.col-5 {width: 41.66%;}
.col-6 {width: 50%;}
.col-7 {width: 58.33%;}
.col-8 {width: 66.66%;}
.col-9 {width: 75%;}
.col-10 {width: 83.33%;}
.col-11 {width: 91.66%;}
.col-12 {width: 100%;}
* {
box-sizing: border-box;
}
答案 1 :(得分:0)
.flex-row {
display: flex;
flex-direction: row;
}
.flex-col{
padding: 15px;
margin: 0 15px;
background: #ddd;
}
.flex-row-multicolum{
display: flex;
flex-direction: row;
flex-wrap: wrap;
flex-flow: row wrap;
}
.flex-row-multicolum .flex-col{ width: 40%; margin: 0 15px 15px}

<h4>1 Row with two colum</h4>
<div class="flex-row">
<div class="flex-col">Colum 1</div>
<div class="flex-col">Colum two</div>
</div>
<h4>1 Row with four colum</h4>
<div class="flex-row">
<div class="flex-col">Colum 1</div>
<div class="flex-col">Colum two</div>
<div class="flex-col">Colum three</div>
<div class="flex-col">Colum four</div>
</div>
<h4>2 Row with two colum</h4>
<div class="flex-row-multicolum">
<div class="flex-col">Colum 1</div>
<div class="flex-col">Colum two</div>
<div class="flex-col">Colum three</div>
<div class="flex-col">Colum four</div>
</div>
&#13;