Create a preview of html page in html page

Deadly 提交于 2021-02-11 13:40:59

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/34217074/create-a-preview-of-html-page-in-html-page

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!