How can I have a position: fixed; behaviour for a flexbox sized element?

前端 未结 5 1662
醉梦人生
醉梦人生 2020-12-02 10:09

I have a div called .side-el which I would like to have in a position: fixed; behavior, but as soon as I apply position fixed the width alternates from the right one. The ri

5条回答
  •  臣服心动
    2020-12-02 11:04

    You can't.

    As explained by the CSS2.1 spec:

    Absolutely positioned boxes are taken out of the normal flow.

    And the Flexible Box Layout spec confirms that:

    An absolutely-positioned child of a flex container does not participate in flex layout. However, it does participate in the reordering step (see order), which has an effect in their painting order.

    (Emphasis mine)

提交回复
热议问题