0

Anyone have any idea how to remove this hole between 2 and 3? I have no idea about this option. Maybe there is any cover? Below is an example in the code

.wrapper {
  display:flex;
  flex-wrap:wrap;
  max-width:320px;
  gap:10px;
  justify-content:flex-end;
}
.box {
  width:150px;
  height:150px;
  background:black;
  color:white;
}

.open {
  height:500px;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div class="wrapper">
  <div class="box open">1</div>
  <div class="box">2</div>
  <div class="box">3</div>
 </div>
</body>
</html>
toma
  • 1

2 Answers2

1

It wasn't entirely clear to me what exactly you wanted to achieve so I'll cover a couple scenarios:

  1. If you want all the boxes to be in one row but in separate columns, I suggest using a percent value for their width instead of a pixel value. 30% should work in your case (there are many ways to achieve this behavior though, this is how I personally would do it).

  2. If, however, you'd like to have box 1 in one column, and boxes 2 and 3 in another column (which is what I think you're going for), then I would suggest adding an additional wrapping div to your HTML, which would wrap boxes 2 and 3. I've modified your code a little to reflect this change, you can see it below. The added div has the class "box-container"; I've also added some necessary CSS.

I hope this was helpful!

.wrapper {
  display:flex;
  flex-wrap:wrap;
  max-width:320px;
  gap:10px;
  justify-content:flex-end;
}

.box-container {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.box {
  width:150px;
  height:150px;
  background:black;
  color:white;
}

.open {
  height:500px;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div class="wrapper">
  <div class="box open">1</div>

  <div class="box-container">
    <div class="box">2</div>
    <div class="box">3</div>
  <div>

 </div>
</body>
</html>
0

You need to add 'flex:1' to '.box' That should solve your issue.

.wrapper {
  display:flex;
  flex-wrap:wrap;
  max-width:320px;
  gap:10px;
  justify-content:flex-end;
}
.box {
  width:150px;
  height:150px;
  background:black;
  color:white;
  flex:1;
}

.open {
  height:500px;
}
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<div class="wrapper">
  <div class="box open">1</div>
  <div class="box">2</div>
  <div class="box">3</div>
 </div>
</body>
</html>
linuxgx
  • 401
  • 2
  • 9