position:fixed and width:inherit with percentage parent

后端 未结 4 1306
清歌不尽
清歌不尽 2021-02-14 03:17

I\'m trying to give a fixed element a width of a percentage parent (here #container). When I use pixel instead of the percentage then it works

4条回答
  •  鱼传尺愫
    2021-02-14 03:32

    It seems as though the static value (250px) can be propagated through normal inheritance. Whereas when the relative value (90%) is being used, the fixed div has already been taken out-of-flow, and now inheritance-wise, it's parent is the viewport. It seems to me that you're going to have to use good old js.

    But, this question is months old now, so it probably doesn't matter either way.

提交回复
热议问题