当前位置:网站首页>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)

边栏推荐
- Native JS implements the copy text function
- 检测vector是否有交集
- MUI登录数据库完善与AJAX异步处理【MUI+Flask+MongoDB+HBuilderX】
- 嵌入式系统概述2-嵌入式系统组成和应用
- 深度学习的多个 loss 是如何平衡的?
- Build an embedded system software development environment - build a cross compilation environment
- In depth anatomy of C language - key words & supplementary contents
- this.$ How to solve the problem when refs is undefined?
- 入门深度学习与机器学习的经验和学习路径
- One line of code to implement shell if else logic
猜你喜欢

Array -- seven array topics with double pointer technique

数组——双指针技巧秒杀七道数组题目

快速下载谷歌云盘大文件的5种方法

Embedded driver design

Pytorch官方Faster R-CNN源代码解析(一)——特征提取

Summary of knowledge points of ES6, ES7, es8, es9, ES10, es11 and ES12 (interview)

442个作者100页论文!谷歌耗时2年发布大模型新基准BIG-Bench | 开源

Advanced C language -- storage of floating point in memory

A "murder case" caused by ES setting operation

实战 | 巧用位姿解算实现单目相机测距
随机推荐
嵌入式系统概述1-嵌入式系统定义、特点和发展历程
八大误区,逐个击破(2):性能差?应用程序少?你对云的这些担心很多余!
Object. Detailed explanation of assign()
Source of routing information
One line of code to implement shell if else logic
[an Xun cup 2019]iamthinking
2022 ARTS|Week 23
Microsoft Word tutorial, how to insert a header or footer in word?
Tuples, arrays, and as const of typescript
Binary tree (serialization)
In depth anatomy of C language - key words & supplementary contents
快速下载谷歌云盘大文件的5种方法
About paiwen
大一女生废话编程爆火!懂不懂编程的看完都拴Q了
入门深度学习与机器学习的经验和学习路径
VTK three views
Typescript and abstract classes
深度学习的多个 loss 是如何平衡的?
嵌入式系统概述2-嵌入式系统组成和应用
MUI登录数据库完善与AJAX异步处理【MUI+Flask+MongoDB+HBuilderX】