Listen to browser width / height changes with jQuery

前端 未结 3 1149
忘掉有多难
忘掉有多难 2020-12-13 13:36

I have some divs that are set with position absolute (CSS) when the page is ready, and are positioned relative to another fixed div, which works fine. However, before the pa

3条回答
  •  孤街浪徒
    2020-12-13 14:26

    It may not be necessary to use JavaScript if you only need to position your element(s) relative to another element instead of the overall document. You can use "position:relative":

    Because myContainer has position:relative, myElement will be positioned absolutely but relative to myContainer instead of relative to the overall document. Armed with this, you can construct quite elaborate, but robust positions that will be browser-size-agnostic.

提交回复
热议问题