flex items going off screen in ios safari

后端 未结 1 514
灰色年华
灰色年华 2021-01-14 13:11

I need to have three blocks in a row. The two on the right will have fixed width. The left block is a text block and should be flexible.

My code works in all resolut

1条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-14 13:46

    An initial setting of a flex container is flex-shrink: 1. This means that flex items can shrink.

    Clearly, Safari handles this behavior differently than other browsers.

    For a cross-browser solution, override the default behavior.

    Add flex-shrink: 0 to the fixed-width items.

    .container {
      display: flex;
      justify-content: flex-end;
    }
    .left {
      border: 1px solid #808080;
    }
    .center {
      border: 1px solid #000;
      padding: 10px;
      margin: 5px;
      flex-shrink: 0;  /* NEW */
    }
    .right {
      border: 1px solid #008000;
      flex-shrink: 0;  /* NEW */
    }
    Lorem ipsum dolor sit amet, consectetur adipisicing elit. Sunt doloribus, nihil deleniti expedita labore porro commodi consequuntur, corporis delectus nam, ipsa? Eius inventore est molestias ex, eos odio. Consequuntur, voluptatibus!
    KK
    18:42

    https://codepen.io/anon/pen/JJMEGp

    0 讨论(0)
提交回复
热议问题