当前位置:网站首页>How to adapt the page size when iframe is embedded in a web page
How to adapt the page size when iframe is embedded in a web page
2022-06-12 12:51:00 【Five flower hourglass】
Problem description :
There is a container in the page div, With width and height attribute . stay div Embed a iframe page , Present this effect :
You can see that only part of the embedded page is exposed .
And we hope : Embedded pages can be completely displayed in containers .
Ideas : utilize CSS Of transform, Zoom the page .
1、 The resolution of the computer screen I developed is 1920 x 1080, On this basis , Set up iframe The width and height of .
2、iframe Parent element of div The width and height of is the width and height of the screen 50%, therefore transform: scale(0.5) This number is 0.5.( The remaining three attributes have nothing to say , Search if you don't understand W3C Well …)
3、 What should be noted is , Better give div Add one overflow: hidden; Properties of , Because sometimes your div The width and height are not exactly scaled as they are now 50%.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>iframe When embedding a web page , How to adapt the page size </title>
</head>
<style> html, body {
width: 100%; height: 100%; } body {
background-color: rgb(228, 228, 228); overflow: hidden; } * {
margin: 0px; padding: 0px; } .iframediv {
width: 50%; height: 50%; margin: 100px auto; border: 10px dashed rgb(58, 58, 58); overflow: hidden; } .iframediv iframe {
width: 1920px; height: 1080px; top: 0; left: 0; transform-origin: top left; transform: scale(0.5) } </style>
<body>
<div class="iframediv">
<iframe src="http://www.hewebgl.com/" frameborder="0"></iframe>
</div>
</body>
</html>
effect :

my div Width and height are 50% The situation of ,transform: scale(0.5) yes 0.5, The effect is shown above .
Then suppose my div wide 40%, high 60% The situation of , How to deal with it ?
There are two kinds of :
1、transform: scale(0.4, 0.6)

2、transform: scale(0.4)

边栏推荐
猜你喜欢

What is the function tag? Article to understand its role and its best practices

Unittest framework

From simple to deep - websocket

El select data echo, display only value but not label

Buu question brushing record - 7

Source of routing information

Deep analysis of advanced pointer -- advanced chapter of C language

Tuples, arrays, and as const of typescript

Influxdb2.x benchmark tool - influxdb comparisons

Overview of embedded system 1- definition, characteristics and development history of embedded system
随机推荐
Binary tree (thoughts)
Newoj week 10 question solution
检测vector是否有交集
ITK 多阶段配准
C语言进阶篇——万字详解指针和qsort函数
[C language] keyword static & Multi file & guessing game
Share PDF HD version, series
[HXBCTF 2021]easywill
常数时间删除/查找数组中的任意元素
itk::Neighborhood获取6邻域、18邻域、26邻域,18/6邻域,26/18邻域
Advanced C language -- storage of deep anatomical data in memory (with exercise)
this.$ How to solve the problem when refs is undefined?
大一女生废话编程爆火!懂不懂编程的看完都拴Q了
Part of the fourth Zhejiang CTF finals
Buu question brushing record - 7
Introduction, installation and use of core JS
Eight misunderstandings are broken one by one (2): poor performance? Fewer applications? You worry a lot about the cloud!
配准后图像对比函数itk::CheckerBoardImageFilter
Three dimensional coordinate point fitting sphere (MATLAB and C)
什么时候运用二分搜索