How can I change the height of an iframe for different screen sizes?

后端 未结 1 1919
遇见更好的自我
遇见更好的自我 2020-12-21 21:26

I have a form that is an iframe. The code is below with a # for what the iframe is. On desktop I need the frame to be 292px in height to match the design. On tablet it need

相关标签:
1条回答
  • 2020-12-21 21:57

    Create a file called responsive.css and add it to your styles. It's good practice to add this file after other css files as you want these rules to take priority over your other css rules.

    This would be the content of your responsive.css

    /* Style for Extra Large Screen */
    @media (max-width:1199px) {
        iframe {
            height: 292px;
        }
    }
    
    /* Style for Large Screen */
    @media (max-width:991px) {
        iframe {
            height: 292px;
        }
    }
    
    /* Style for Medium Screen */
    @media (max-width:767px) {
        iframe {
            height: 180px;
        }
    }
    
    /* Style for Small Screen */
    @media (max-width:575px) {
        iframe {
            height: /* whatever height you want for mobile */
        }
    }
    

    Depending on your screen size, the correct section of responsive.css will be used in your website. For example, if you are on mobile, then @media (max-width:575px) will be selected. Just put your required height in here.

    0 讨论(0)
提交回复
热议问题