Media queries not working inside an iframe

前端 未结 4 693
生来不讨喜
生来不讨喜 2020-12-02 23:02

I have in a webpage which is responsive. It makes use of media queries.

But the same page loaded in an iframe is not working.

For example, consider to my web

4条回答
  •  忘掉有多难
    2020-12-02 23:53

    Try it this way, instead of device just target the width

    Change

    @media only screen and (max-device-width : 640px) {
    

    to

    @media only screen and (max-width : 640px) {
    

    Also, it is more advised to target both min and max view-port width if you want to avoid considering order of media query declarations in your style-sheet

    @media screen and (min-width: 320px) and (max-width: 640px) {
        .header-text {
           background-color: blue;
        }
    }
    

提交回复
热议问题