CSS 我需要将整个网站缩小到 80%

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9036927/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 02:45:54  来源:igfitidea点击:

I need to scale an entire website down to 80%

css

提问by 3x5

I just built out a website for a client, based on the Photoshop files they sent me, and they came back and told me that somehow the PSDs were 125% the size they were supposed to be, and that they need be to shrink everything to 80% of what it is now.

我刚刚根据他们发送给我的 Photoshop 文件为客户建立了一个网站,他们回来告诉我不知何故 PSD 的大小是他们应有的大小的 125%,他们需要将所有内容缩小到现在的80%。

I figure I'm going to need to re-cut all the images, but I would rather not rewrite the CSS so I'm exploring alternatives.

我想我需要重新剪切所有图像,但我宁愿不重写 CSS,所以我正在探索替代方案。

Currently, all values are in pixels. I'm wondering if I should try to find a script that would take all the pixel values and multiply by .8, or if I should use a px to em converter and then set the base size in the html tag to 80%, or if there is better way to fix this problem.

目前,所有值都以像素为单位。我想知道我是否应该尝试找到一个脚本来获取所有像素值并乘以 0.8,或者我是否应该使用 px 到 em 转换器,然后将 html 标签中的基本大小设置为 80%,或者如果有更好的方法来解决这个问题。

回答by xec

Ugly css hack alert! :D

丑陋的 css 黑客警报!:D

html {
    zoom: 0.8; /* Old IE only */
    -moz-transform: scale(0.8);
    -webkit-transform: scale(0.8);
    transform: scale(0.8);
}

Update

更新

It appears latest Chromeand IE10supports (and applies) bothzoomand transformat the same time, scaling it twice, so I recommend only using zoomwhen testing old IE browsers.

看来最新的ChromeIE10支持(和应用)zoomtransform在同一时间,缩放两次,所以我建议只使用zoom测试旧IE浏览器的时候。

回答by Zach

You can re-size the page inside of an iframe that is at 80% width. You would need to remove the borders and turn scrolling of but it should work.

您可以在宽度为 80% 的 iframe 内重新调整页面大小。您需要删除边框并滚动,但它应该可以工作。

Tutorial here How can I scale the content of an iframe?

此处的教程 如何缩放 iframe 的内容?

I haven't tried it but it seems like it could possibly be sketchy as far a browser compatibility and bugs if you ask me. just thought i would pass it along

我还没有尝试过,但如果你问我,就浏览器兼容性和错误而言,它似乎可能是粗略的。只是想我会把它传递下去