简体   繁体   English

身体最大高度 纵横比 放大

[英]body max-height; aspect-ratio; zoom

I have written a beautifully responsive c#-MVC web application designed for laptops (the compilation and alpha test environment); 我已经编写了一个用于笔记本电脑的漂亮的​​响应式c#-MVC Web应用程序(编译和alpha测试环境); however, after deploying, it does not appear correctly on android devices. 但是,部署后,它在Android设备上无法正确显示。 The text is tiny when devices are flipped in portrait. 当设备纵向翻转时,文本很小。 I have invested about a day into hacking together a semi-aesthetic vertically responsive design for Android when I had what is hopefully an epiphany. 当我有一个顿悟的时候,我已经花了大约一天的时间来破解Android的半美学垂直响应设计。 Is it possible to set the max-height of the body and auto-zoom the page? 是否可以设置主体的最大高度并自动缩放页面? Does anybody have experience with this idea who can guide me? 有人可以指导我吗? I would just do it and test, but doing so requires me to really commit and revert to a previous version, then re-migrate from Xamarin to VS (if it's possible then it's the easiest way, otherwise it is a huge time investment). 我会做并测试,但是这样做需要我真正提交并还原到以前的版本,然后从Xamarin重新迁移到VS(如果可能的话,这是最简单的方法,否则将花费大量时间)。 The target device is Samsung S4, so I can use any viewport or zoom solutions it supports. 目标设备是Samsung S4,因此我可以使用它支持的任何视口或缩放解决方案。

NOTE: I will keep this question open in case somebody comes up with another answer, as this solution can potentially help a lot of developers. 注意:如果有人想出另一个答案,我将保留此问题,因为此解决方案可能会帮助很多开发人员。 The solution that worked for me was: 对我有用的解决方案是:

Place a Viewport meta tag in the _Layout.cshtml page: 将视口元标记放置在_Layout.cshtml页面中:

<meta name="viewport" content="initial-scale=1">

Next, in the javascript file, put (these should be combined, but I'm showing them one at a time for descriptive purposes): 接下来,在javascript文件中放(这些应结合使用,但出于描述目的,我一次将它们展示一次):

document.getElementById("viewport").setAttribute("content", "height=600");
document.getElementById("viewport").setAttribute("content", "device-width=800");

Adjust paramters as desired. 根据需要调整参数。

I believe you are missing the width attribute in your meta tag. 我相信您在元标记中缺少width属性。

<meta name="viewport" content="width=device-width, initial-scale=1">

To disable zooming (may be necessary depending on the application): 要禁用缩放(根据应用程序可能是必要的):

<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

In addition to that, how are you setting your font sizes? 除此之外,如何设置字体大小? Only set a pixel value on the body tag, without setting this, the browser will use a device default, usually ~16px for desktop. 仅在body标签上设置像素值,而不设置该值,浏览器将使用设备默认值,对于台式机通常为〜16px。

With a base font weight set, utilize EMs to size the other elements relative to the body font size. 设置基本字体粗细后,利用EM调整其他元素相对于正文字体大小的大小。 This makes it very easy to change base font for smaller screens with a media query. 这使得通过媒体查询为较小的屏幕更改基本字体变得非常容易。 Such as: 如:

@media (max-width: 400px) {
    body {
       font-size: 14px
    }
}

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM