Media queries fail inside IE9 iframe

前端 未结 5 1594
小蘑菇
小蘑菇 2020-12-14 18:33

I have the following media queries in my CSS:

@media screen and (min-width: 0px) and (max-width: 319px) {
    body {background-color:red;}
}

@media screen a         


        
5条回答
  •  被撕碎了的回忆
    2020-12-14 19:14

    Not a real answer but could help somebody else find a work around for this bug in IE.

    Page containing iframes

    
    

    Iframe pages

    
    

    The param frameX prevents IE from caching the css page and thus the iframe has responsive layout independently from the other pages. This is just a hack(horrible one) and to help somebody else find the answer to this problem.

    Sample files

    Index.html

    
    
    
        Title
        
        
    
    
      


    250px frame
    350px frame
    390px frame

    frame1.html

    
    
    
        Title
        
        
    
    
      

    frame2.html

    
    
    
        Title
        
        
    
    
      

    frame3.html

    
    
    
        Title
        
        
    
    
      

    style.css

    iframe{display:block;}
    
    @media (max-width: 8000px)
    {
      body p:before {content: "bigger than 550px";}
    }
    
    @media (max-width: 550px)
    {
      body p:before {content: "max550";}
    }
    
    @media (max-width: 450px)
    {
      body p:before {content: "max450";}
    }
    
    @media (max-width: 350px)
    {
      body p:before {content: "max350";}
    }
    
    
    @media (max-width: 250px)
    {
      body p:before {content: "max250";}
    }
    

提交回复
热议问题