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.stack.imgur.com/YrzCV.png

borkafight
  • 487
  • 1
  • 5
  • 10

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
  • 64,305
  • 18
  • 73
  • 130
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
  • 6,038
  • 19
  • 75
  • 149
mjarenyap
  • 1
  • 2