Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

possible to shrink contents of iframe?

Is there a way to shrink what's inside an iframe without adjusting css?

any magical 'zoom' parameter out there?!!!

I have a 600px preview iframe i want to fit a 1000px site in without scrollbars...

like image 816
Haroldo Avatar asked Apr 13 '10 14:04

Haroldo


People also ask

How can I scale the content of an iframe?

Just multiply the original dimensions by the zoom ration you want to use. For example, if you want to scale to 71% as shown in the example below, 1000px x 2000px becomes 710px x 1420px. The zoom factor is input for the zoom , -moz-transform , -o-transform , and -webkit-transform properties.

Can iframe be resized?

You can easily resize iFrames using HTML and/or CSS, and even make them resizable so they'll adjust automatically based on the user's screen size.

Can you modify iframe content?

When you can communicate with the code inside an iFrame, you can make any change you want to the code within that iFrame.


2 Answers

CSS3 can handle this. This bit of code should handle most all browsers or simply reduce it to fit your needs. No need to "adjust" any existing CSS:

iframe {   -moz-transform: scale(0.25, 0.25);    -webkit-transform: scale(0.25, 0.25);    -o-transform: scale(0.25, 0.25);   -ms-transform: scale(0.25, 0.25);   transform: scale(0.25, 0.25);    -moz-transform-origin: top left;   -webkit-transform-origin: top left;   -o-transform-origin: top left;   -ms-transform-origin: top left;   transform-origin: top left; } 

Or if you want inline style for example just firefox:

<style>   #IDNAME {     -moz-transform: scale(0.25, 0.25);      -moz-transform-origin: top left;   } </style> 

Then of course simply add the ID to your iframe:

<iframe id="IDNAME" src="http://www.whatever.com"></iframe> 
like image 167
Justin Emlay Avatar answered Sep 21 '22 01:09

Justin Emlay


If you control the Iframe-content, you might find this little hack of mine useful: http://futtta.be/squeezeFrame/

It's a cross-browser standalone javascript thingy that tries to automatically adjust the size of the page it's called from to the available size of the Iframe using css zoom and moz-transform.

like image 27
futtta Avatar answered Sep 21 '22 01:09

futtta