Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

flexbox ios space distribution issues

Take a look at this image:

enter image description here

As you can see the 2 end links break out of the anchor container.

This is only happening on an iPad (using simulator to test).

On the desktop it behaves as it should by breaking the words in the other links allowing for more space to distribute the remaining items.

It's as if ios doesn't know how to properly break the text in the first link.

.nav-section {
  padding: 0 30px;
}
.nav-section__list {
  display: inline-flex;
  align-items: stretch;
  margin: 0 auto;
}
.nav-section__item {
  padding: 0 20px;
}

.nav-section__link {
  display: block;
  background: red;
}
<nav class="nav-section">
  <div class="nav-section__list">

    <div class="nav-section__item">
      <a href="#" class="nav-section__link">AAAAA AAAA-AAAAAAAA AAAAAAAAA</a>
    </div>

    <div class="nav-section__item">
      <a href="#" class="nav-section__link">AAA AAAAAAAA AAAAAAAAAA</a>
    </div>

    <div class="nav-section__item">
      <a href="#" class="nav-section__link">AAAAAAAAAAA</a>
    </div>

    <div class="nav-section__item">
      <a href="#" class="nav-section__link">AAAAAAA</a>
    </div>

  </div>
</nav>

Update

  • word-break: break-all is not a valid solution:

enter image description here

  • word-wrap: break-all also doesn't work:

enter image description here

This is the same resolution but on a desktop:

enter image description here

As you can see the way the words break is completely different. The iPad just doesn't want to co-operate.

Update 2

I have run into the same issue in another instance of flexbox. It seems like IOS still has some bugs with the implementation.

So I went ahead and used display: table; and display: table-cell; just until the issue is resolved.

If anybody has any other hints as to exactly why the issue might be happening that would be great. Thanks!

like image 606
MarioD Avatar asked Aug 05 '16 15:08

MarioD


People also ask

Why is flex space between not working?

The justify-content property applies only to a flex container. In your code, justify-content is applied to the items, so it's having no effect. Re-assign it to the container. Of course, an element can be both a flex container and item, in which case all properties apply.

How do I add space between items in flexbox?

To set space between the flexbox you can use the flexbox property justify-content you can also visit all the property in that link. We can use the justify-content property of a flex container to set space between the flexbox.

How do you show 3 items per row in flexbox?

For 3 items per row, add on the flex items: flex-basis: 33.333333% You can also use the flex 's shorthand like the following: flex: 0 0 33.333333% => which also means flex-basis: 33.333333% .


1 Answers

Flexbox is relatively new, and browsers may have implemented it a little diferently from each other. You may be missing the -webkit-prefix, as it looks like safari did need it on some versions.

display: -webkit-inline-flex;
display: inline-flex;
-webkit-align-items: stretch;
align-items: stretch;

Or, maybe you could try using:

word-break: break-all;

To ensure that those words will be broken, and will not overflow.

like image 120
Miguel Vieira Avatar answered Oct 10 '22 11:10

Miguel Vieira