简体   繁体   English

如何将容器 div 及其所有内容缩放到特定大小?

[英]How to zoom container div and all its contents to a specific size?

I created an HTML page with 100% (browser) width which have lot of contents.我创建了一个 100%(浏览器)宽度的 HTML 页面,其中包含很多内容。 Contents are fixed in page and their sizes are both in pixels & percentages.内容在页面中是固定的,它们的大小都以像素和百分比为单位。
Now I need to add advertisement panel of 20% browser width.现在我需要添加 20% 浏览器宽度的广告面板。 And want to zoom the page container and all its contents INCLUDING TEXT to 80% (like the zooming available in all web browsers but it should be an internal zooming).并且想要将页面容器及其所有内容包括文本缩放到 80% (就像所有 Web 浏览器中可用的缩放一样,但它应该是内部缩放)。
Unfortunately my page is not responsive and I do not want to redevelop it or resize all its contents from scratch.不幸的是,我的页面没有响应,我不想重新开发它或从头开始调整其所有内容的大小。
Is there any zooming facility available in HTML? HTML 中有任何可用的缩放工具吗?

you can use css transform property您可以使用 css 变换属性

     transform: scale(0.1);
     transform-origin: 0% 0% 0px;

have a look at the zooming functionality i have created看看我创建的缩放功能

 function setZoom(zoom,el) { transformOrigin = [0,0]; el = el || instance.getContainer(); var p = ["webkit", "moz", "ms", "o"], s = "scale(" + zoom + ")", oString = (transformOrigin[0] * 100) + "% " + (transformOrigin[1] * 100) + "%"; for (var i = 0; i < p.length; i++) { el.style[p[i] + "Transform"] = s; el.style[p[i] + "TransformOrigin"] = oString; } el.style["transform"] = s; el.style["transformOrigin"] = oString; } //setZoom(5,document.getElementsByClassName('container')[0]); function showVal(a){ var zoomScale = Number(a)/10; setZoom(zoomScale,document.getElementsByClassName('container')[0]) }
 .container{ width:500px; height:500px; background:blue; }
 <input id="test" min="1" max="10" value='10' step="1" onchange="showVal(this.value)" type="range"/> <div class="container"> </div>

I have tried making a zoom-in and zoom-out functionality using plain HTML, CSS and Javascript have a look.我曾尝试使用纯 HTML、CSS 和 Javascript 来制作放大和缩小功能,看看吧。 s

https://codepen.io/ghewadesumit/pen/poJEYVG?editors=1111 https://codepen.io/ghewadesumit/pen/poJEYVG?editors=1111

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当div的内容发生变化时,如何自动调整div的大小? - How do I resize a div automatically to the size of its contents when the contents of the div have changed? 减少div的大小及其所有内容以适合较小的div jquery和php - reduce size of a div plus all its contents to fit in a smaller div jquery and php 如何使用ngAnimate滑动div及其所有内容? - How do I slide a div and all of its contents using ngAnimate? 如何创建一个将自动自动换行内容的div,以便div的水平方向永远不会比其容器大? - How to create a div that will automatically word wrap the contents so that the div will never grow horizontally larger than its container? 如何按父div缩放内部内容? - How to zoom inner contents as per the parent div? 是否可以缩放HTML DIV及其所有内容? - Is it possible to scale a HTML DIV with all its contents? 动态调整 div 的 css 缩放以适应容器的大小 - Dynamically adjust a div's css zoom to fit container's size 如何在不增加图像尺寸的情况下放大图像? - how to zoom in an image without increasing its size? JavaScript 放大 DIV 中心,而不改变其大小 - JavaScript Zoom in on DIV center, without changing its size 当我们减小浏览器的缩放大小时如何隐藏特定的 div 元素 - How to hide a specific div element when we reduce the zoom size of a browser
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM