I have the following code:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<style>
*,
*:before,
*:after {
box-sizing: border-box;
}
.list {
line-height: 22px;
}
.list:before,
list:after {
display: table;
content: "";
}
.list:after {
clear: both;
}
.right-item {
float: left;
width: 50px;
height: 50px;
display: table;
background-color: blue;
border: 1px solid green;
display: table;
float: left;
width: 50px;
height: 50px;
margin-right: 8px;
margin-bottom: 8px;
text-align: center;
vertical-align: top;
}
.wrapper {
display: inline-block;
width: 100%;
}
.wrapper:before,
.wrapper:after {
content: "";
display: table;
}
.wrapper:after {
clear: both;
}
.floated-item {
float: left;
width: 50px;
height: 50px;
background-color: red;
border: 1px solid black;
margin: 0 8px 8px 0;
}
.flex-item {
flex: auto;
max-width: 100%;
}
.flex-container {
display: flex;
align-items: center;
min-height: 15px;
position: relative;
align-items: center;
}
.flex-column {
display: flex;
flex-direction: column;
flex-grow: 1;
min-height: 1px;
position: relative;
max-width: 100%;
}
.outer-wrapper {
display: flex;
flex-flow: column wrap;
margin-bottom: 24px;
vertical-align: top;
}
.label {
flex-grow: 0;
overflow: hidden;
display: inline-block;
position: relative;
max-width: 100%;
min-height: 1px;
}
.label-inner {
height: auto;
position: relative;
display: inline-flex;
align-items: center;
margin: 0;
}
</style>
</head>
<body>
<form>
<div class="outer-wrapper">
<div class="label"><label class="label-inner">Label</label></div>
<div class="flex-column">
<div class="flex-container">
<div class="flex-item">
<span class="wrapper">
<div class="list">
<div class="floated-item">
<span><div class="floated-item"></div></span>
</div>
<div class="floated-item">
<span><div class="floated-item"></div></span>
</div>
<div class="floated-item">
<span><div class="floated-item"></div></span>
</div>
<div class="floated-item">
<span><div class="floated-item"></div></span>
</div>
<div class="floated-item">
<span><div class="floated-item"></div></span>
</div>
</div>
<div class="right-item"></div>
</span>
</div>
</div>
</div>
</div>
</form>
<div>content</div>
</body>
</html>
At first, I didn't have a clue what happens with the added extra space. After a long debugging, the problem is (at least it seems to be, it fixes the extra space, but maybe something else causes it, I don't know) that flex-wrap: wrap
is used on the .outer-wrapper
. When I set it to flex-wrap: nowrap
it fixes the extra space.
I went through the Flexbox specification, and also through the Visual Formatting Model of the CSS spec, about float usage, formatting contexts, etc. but I still don't know what might be the problem.