Search code examples
htmlcssmedia-queries

Html5/CSS3 Media Query


I made a new html document with only a PDF-file in it. The code:

<embed src="impressum.pdf" width="1200" height="900" alt="pdf" pluginspage="http://www.adobe.com/products/acrobat/readstep2.html">

It workes perfectly but my problem is now, that I don´t know how to format it for the smartphone view. I started with the regular Media Query code in css and don´t know what I should put in there:

@media screen and (max-width: 800px) {  
} 

Solution

  • You can simply set the height and with to a 100% for the embed and set the body height to 100vh:

    body {
            height: 100vh;
            overflow: hidden;
        }
    

    Like this, the pdf will always have the correct width no matter what device you open it on.

    <body>
        <embed src="impressum.pdf" width="100%" height="100%" alt="pdf" pluginspage="http://www.adobe.com/products/acrobat/readstep2.html">
    </body>