gpt4 book ai didi

html - flex 列不匹配

转载 作者:行者123 更新时间:2023-11-28 00:57:02 24 4
gpt4 key购买 nike

<分区>

我有两个 flex 行。第一行有 6 个相等的列,带有 flex: 1。第二行包含带有 flex:4 的列和带有 flex:2 的列。列设置了 margin-right: 10px,除了一行中的最后一个子项。

http://jsbin.com/gufihoyaha/edit?html,css,output

.row {
display: flex;
}

.row .col {
margin-right: 10px;
background-color: coral;
}

.row .col:last-child {
margin-right: 0;
}

.flex-1 {
flex: 1;
}

.flex-4 {
flex: 4;
}

.flex-2 {
flex: 2;
}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
</head>
<body>
<div class="row">
<div class="col flex-1">1</div>
<div class="col flex-1">1</div>
<div class="col flex-1">1</div>
<div class="col flex-1">1</div>
<div class="col flex-1">1</div>
<div class="col flex-1">1</div>
</div>
<div class="row">
<div class="col flex-4">4</div>
<div class="col flex-2">2</div>
</div>
</body>
</html>

但是结果和我预想的不一样:

enter image description here

我想要的是这样的:

enter image description here

问题:为什么会发生这种情况以及如何解决?

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com