Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
289 views
in Technique[技术] by (71.8m points)

html - Resize iframe without changing page viewport

I have an iframe that is loaded inside a laptop png image. I want the iframe to simulate a desktop screen however I am not sure how to make the iframe resize itself to fit perfectly inside the screen without the viewport changing to mobile.

My current solution fits inside the screen however the iframe changes to the mobile viewport which I don't want http://jsfiddle.net/chaudim/d57krjph/1/

example.html

<div>
    <div>
        <iframe width="560" height="315" src="//www.plaid.com" frameborder="0" allowfullscreen></iframe>
   </div>
</div>

example.css

div {
    width: 100%;
    height: 100%;
    max-width: 1034px;
    max-height: 543px;
    margin: 0 auto;
}
div div {
    position: relative;
    padding-top: 25px;
    padding-bottom: 67.5%;
    height: 0;
}
div iframe {
    box-sizing: border-box;
    background: url(http://i.stack.imgur.com/zZNgk.png) center center no-repeat;
    background-size: contain;
    padding: 11.9% 15.5% 14.8%;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

enter image description here

question from:https://stackoverflow.com/questions/65938833/resize-iframe-without-changing-page-viewport

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...