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
786 views
in Technique[技术] by (71.8m points)

css - Create a preview of html page in html page

I need to create an html page containing preview or scaled view of some html pages. I tried to implement this using iframe and scaling the iframe. By display it is looking good.But even after iframe is scaled it takes the width and height of iframe content. Is there any solution for this?

 <html>
    <head>
    <style type="text/css">
    #viewCollasheRow1 {
        table-layout: fixed;
        width: 100%;
        height: 35%;
    }

    .viewCollasheColumn1 {
        width: 445px;
        height: 192px;
        padding: 0;
        overflow: hidden;
    }
    .viewCollasheColumn1Content {
        width: 1775px;
        height: 760px;
        -ms-transform: scale(0.25);
        -moz-transform: scale(0.25);
        -o-transform: scale(0.25);
        -webkit-transform: scale(0.25);
        transform: scale(0.25);
        -ms-transform-origin: 0 0;
        -moz-transform-origin: 0 0;
        -o-transform-origin: 0 0;
        -webkit-transform-origin: 0 0;
        transform-origin: 0 0;
    }
    </style>
    </head>
    <body>
        <
        <table id="viewCollasheRow1">
            <tr>
                <td class="viewCollasheColumn1"><iframe id="viewLabelFrame"
                        class="viewCollasheColumn1Content" src="./iframe1.html"
                        scrolling="no"></iframe></td>
                <td class="viewCollasheColumn1"><iframe id="viewLabelFrame"
                        class="viewCollasheColumn1Content" src="./iframe1.html"
                        scrolling="no"></iframe></td>

            </tr>
        </table>
    </body>
    </html>

Iframe content html page

<html>
<head>
<style type="text/css">
#testDiv {
    width: 100%;
    height: 100%;
}
</style>
</head>
<body>
    <div id="testDiv"></div>
</body>
</html>

Any help will be realy helpful.

See Question&Answers more detail:os

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

1 Answer

0 votes
by (71.8m points)

If you were to give the iframe a height of 100% and the parent div the desired height, I believe you'll get the desired effect.

An excerpt from your css:

.viewCollasheColumn1Content {
    width: 1775px;
    height: 100%;
    -ms-transform: scale(0.25);
    -moz-transform: scale(0.25);
    -o-transform: scale(0.25);
    -webkit-transform: scale(0.25);
    transform: scale(0.25);
    -ms-transform-origin: 0 0;
    -moz-transform-origin: 0 0;
    -o-transform-origin: 0 0;
    -webkit-transform-origin: 0 0;
    transform-origin: 0 0;
}

https://jsfiddle.net/9sc3eqvk/

Maybe I misunderstand your question though. The iframe's parent div will control the iframe's height and what is visible. Setting the iframe to 100% ensures that it fills the parent div.


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

...