[英]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.