php 以编程方式为网页设置默认缩放?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13469067/
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-25 05:30:19  来源:igfitidea点击:

Set default zoom for web page programmatically?

phphtmlcss

提问by user1820652

Is it possible to set the default zoom level on a site? For instance, could I code my sitein such as a way that it is zoomed to 125% when a user opens it?

是否可以在网站上设置默认缩放级别?例如,我是否可以对我的网站进行编码,以便在用户打开它时将其放大到 125%?

My website body has this code

我的网站正文有此代码

<body ID="phpbb" class="section-{SCRIPT_NAME} {S_CONTENT_DIRECTION}"> 

How to put this zoom code inside?

如何把这个缩放代码放在里面?

回答by Sowmya

Add zoom: 125%;to body style

添加zoom: 125%;到体型

body {
color: #536482;
background-color: white;
zoom: 125%;
}

回答by Brad

This does not directly answer your question, but is an alternative that I recommend considering.

这不能直接回答您的问题,而是我建议考虑的替代方案。

If you use relative sizing for your page (such as em), then you can set the base size of the site in one place, and the whole page will scale up and down accordingly.

如果您对页面使用相对大小(例如em),那么您可以在一个地方设置站点的基本大小,整个页面将相应地放大和缩小。

For instance, if I want 125% of default size:

例如,如果我想要 125% 的默认大小:

body { font-size: 1.25em }

Then, suppose I want a reasonable amount of margin around a header <div>:

然后,假设我想在标题周围留出合理的边距<div>

#header { margin: 1em }

If I then go back and change that base size on the body to something else, the margin on my header will scale with it. If you do your entire page in relative units, this becomes very easy to do.

如果我然后返回并将主体上的基本尺寸更改为其他尺寸,则标题上的边距将随之缩放。如果您以相对单位完成整个页面,这将变得非常容易。

回答by Sébastien Renauld

You might want to check the zoomCSS attribute. Bear in mind however that it is part of CSS3 and that, therefore, you might find it to behave oddly on old IEs. This is also completely separate from the interface zoom.

您可能需要检查zoomCSS 属性。但是请记住,它是 CSS3 的一部分,因此,您可能会发现它在旧 IE 上的行为很奇怪。这也与界面缩放完全分开。

回答by Ketan Ramani

webView.setInitialScale((int) getResources().getDimension(R.dimen._50sdp));
                            webView.getSettings().setLoadsImagesAutomatically(true);
                            webView.getSettings().setJavaScriptEnabled(true);
                            webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
                            webView.loadDataWithBaseURL(null,htmlContent,"text/html","UTF-8", null);
                            webView.getSettings().setBuiltInZoomControls(true);
                            webView.getSettings().setSupportZoom(true);
                            webView.getSettings().setDisplayZoomControls(true);
                            webView.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);