简体   繁体   English

HTML / CSS / JAVASCRIPT - 缩放固定大小的项目以适应流体容器

[英]HTML / CSS / JAVASCRIPT - scaling fixed sized items to fit into a fluid container

I was wondering if anyone else has hit this problem? 我想知道是否有其他人遇到过这个问题? My goal is to scale some fixed sized divs with text and images to fit within a fluid div container. 我的目标是使用文本和图像缩放一些固定大小的div,以适应流体div容器。 Here is a more detailed explanation: 这是一个更详细的解释:

I have to give an as accurate as possible preview of a print layout in HTML so I am setting my item sizes to MM for dimensions and to PT for text, this allows me to copy an existing print layout accurately. 我必须尽可能准确地预览HTML中的打印布局,因此我将项目大小设置为MM以获取尺寸,将PT设置为文本PT,这样我就可以准确地复制现有的打印布局。 Now my problem is that I need these page previews to fit in a div which would be set to say 80% height. 现在我的问题是我需要这些页面预览适合div,设置为80%高度。 I am struggling with this one as I can't think of an easy way to convert lots of MM and PT measurements into percentages, So I thought maybe there could be some involvement of JavaScript? 我正在努力解决这个问题,因为我无法想到将大量MM和PT测量转换成百分比的简单方法,所以我想也许可能有一些JavaScript的参与?

Any help would be appreciated. 任何帮助,将不胜感激。

Jquery and CSS where used to solve this in the end. Jquery和CSS最终用来解决这个问题。 There is a css property named zoom. 有一个名为zoom的css属性。 This can be increased or decreased using the below example: 可以使用以下示例增加或减少:

$('.zoomMinus').click(function ( ){
        zoom -= 10;
        $("#divtozoom").css('zoom', zoom + "%");


    });
 $('.zoomPlus').click(function ( ){
        zoom += 10;
        $("#divtozoom").css('zoom', zoom + "%");
    }); 

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

相关问题 CSS或Javascript:如何在宽度可变的容器中并排放置两个肖像图像? - CSS or Javascript: How to fit two portrait images side by side in a container with fluid width? CSS HTML:父级扩展和子级位置是否有解决方法:已修复? - CSS HTML: Is there workaround for parent scaling and child position:fixed? 确定JavaScript中的可变宽度或固定宽度 - Determine fluid or fixed width in JavaScript 使用 CSS 网格隐藏仅部分适合容器的项目 - Hide items that only partially fit in the container using CSS grid 如何裁剪多个HTML段落标签以使其适合使用CSS3或JavaScript(文本溢出,截断等)的显式尺寸的框? - How do you crop multiple HTML paragraph tags to fit into an explicitly sized box with CSS3 or JavaScript (text-overflow, truncate, etc.)? 在圆形容器中放入100个物品,并用javascript均匀隔开 - Fit 100 items in a circular container, evenly spaced with javascript CSS固定网格(缩放时的偏移量) - CSS fixed grid (offsetting on scaling) CSS布局的相对宽度,固定混合 - Relative width for a CSS layout, fixed and fluid mix 使用javascript调整textarea以适应流畅的宽度布局 - resize textarea to fit in a fluid width layout with javascript Fluid Dynamic CSS-Javascript / jQuery - Fluid Dynamic CSS - Javascript/jQuery
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM