1

Do you have an idea how to align the last string in flexbox block?

.wrapper {
  display: flex;
  flex-flow: row wrap;
}

.wrapper p {
  flex: auto;
  width: 200px;
}
<div class="wrapper">
  <p>A</p>
  <p>B</p>
  <p>C</p>
  <p>D</p>
  <p>E</p>
  <p>F</p>
  <p>G</p>
  <p>H</p>
  <p>I</p>
  <p>J</p>
</div>

Everything works fine but the last string breaks blocks not as good as I wanted. On the screenshot below you can see behavior of the block and my red notes how I wanted.

Image

Thanks a lot for any help!

-- EDITED --

Sorry, I didn't specify that I wanted save full width of wrapper tag. If I remove flex: auto; from child blocks it became not full width https://i.imgur.com/Bb932yA.png

borkafight
  • 367
  • 1
  • 3
  • 9

2 Answers2

1

Just remove flex: auto; from the rule for .wrapper p:

.wrapper {
  display: flex;
  flex-flow: row wrap;
}

.wrapper p {
  width: 200px;
}
<div class="wrapper">
  <p>A</p>
  <p>B</p>
  <p>C</p>
  <p>D</p>
  <p>E</p>
  <p>F</p>
  <p>G</p>
  <p>H</p>
  <p>I</p>
  <p>J</p>
  <p>K</p>
</div>
Johannes
  • 59,058
  • 16
  • 59
  • 114
0

Try removing the flex:auto; from your code.

.wrapper {
  display: flex;
  flex-flow: row wrap;
}

.wrapper p {
  width: 200px;
}
<div class="wrapper">
  <p>A</p>
  <p>B</p>
  <p>C</p>
  <p>D</p>
  <p>E</p>
  <p>F</p>
  <p>G</p>
  <p>H</p>
  <p>I</p>
  <p>J</p>
</div>
demo
  • 5,676
  • 16
  • 65
  • 141
mjarenyap
  • 1
  • 2