Triggering jquery with css media queries

前端 未结 3 1732
囚心锁ツ
囚心锁ツ 2020-11-29 07:02

I am using css media queries on my project to create a site that will work with any sized screen. I am looking to trigger difference jquery functions just like I would with

3条回答
  •  情书的邮戳
    2020-11-29 07:25

    I had a similar problem with some carousels that must be created on mobile, but destroyed in desktop... and I did not liked the solution of being checking window width in pixels, so I created a small function to "listen" when the mediaquery state changes, without the need of Modernizr.

    You can define your own code in every state ("on entering mobile resolution", "on leaving desktop")... and there put your code.

    Hope could be useful for someone else ;)
    https://github.com/carloscabo/MQBE
    (improvements and ideas are welcome ;)

提交回复
热议问题