The Internet is developing faster and faster, and various technologies are emerging one after another. The display sizes and resolutions of various devices are different. This is also a problem that our front-end personnel are currently struggling with: how to develop once and be friendly on different interfaces. Show it!
Fortunately Viewport appears in HTML5! The emergence of Viewport allows the applications or pages we develop to be displayed uniformly and friendly on devices of different sizes!
viewport syntax introduction:
<!– html document –> <meta name=”viewport” content=” height = [pixel_value | device-height] , width = [pixel_value | device-width ] , initial-scale = float_value , minimum-scale = float_value , maximum-scale = float_value , user-scalable = [yes | no] , target-densitydpi = [dpi_value | device-dpi | high-dpi | medium-dpi | low-dpi] ” />
Parameter explanation:
width - controls the size of the viewport. You can specify a value or a special value. For example, device-width is the width of the device (unit is CSS pixels when scaling to 100%).
height - corresponds to width, specifies the height
target-densitydpi - a screen pixel density is determined by the screen resolution, usually defined as the number of dots per inch (dpi) . Android Supports three screen pixel densities: low pixel density, medium pixel density, and high pixel density. A low pixel density screen has fewer pixels per inch, while a high pixel density screen has more pixels per inch. Android Browser and WebView default screens are medium pixel density.
The following is the value range of the target-densitydpi attribute
device-dpi: Use the original dpi of the device as the target dp. Default scaling does not occur.
high-dpi: Use hdpi as the target dpi. Medium pixel density and low pixel density devices scale down accordingly.
medium-dpi: Use mdpi as the target dpi. Devices with high pixel density scale up accordingly, and devices with pixel density scale down accordingly. This is the default target density.
low-dpi: Use mdpi as the target dpi. Medium pixel density and high pixel density devices scale up accordingly.
<!– html document –> <meta name=”viewport” content=”target-densitydpi=device-dpi” /> <meta name=”viewport” content=”target-densitydpi=high-dpi” /> <meta name=”viewport” content=”target-densitydpi=medium-dpi” /> <meta name=”viewport” content=”target-densitydpi=low-dpi” /> <meta name=”viewport” content=”target-densitydpi=200″ />
To prevent Android Browser and WebView from scaling your page based on the pixel density of different screens, you can set the viewport's target-densitydpi to device-dpi. When you do this, the page will not scale. Instead, the page is displayed based on the pixel density of the current screen. In this case, you also need to define the viewport's width to match the device's width so that your page can fit on the screen.
initial-scale——Initial scaling. That is, the initial zoom level of the page. This is a floating point value that is a multiplier of the page size. For example, if you set the initial scaling to "1.0", then the web page will be displayed at 1:1 of the target density resolution when displayed. If you set it to "2.0", then the page will be enlarged to 2 times.
maximum-scale——Maximum scaling. That is, the maximum degree of scaling allowed. This is also a floating point value indicating the maximum multiplier of the page size compared to the screen size. For example, if you set this value to "2.0", then the page can be enlarged up to 2 times compared to the target size.
user-scalable – User-adjustable scaling. That is, whether the user can change the zoom level of the page. If set to yes, the user is allowed to change it, otherwise it is no. The default value is yes. If you set it to no, both minimum-scale and maximum-scale will be ignored, since scaling is not possible at all.
All scaling values must be within the range of 0.01–10.
Example: 1. Set the screen width to the device width, prohibit the user from manually adjusting the zoom
<meta name=”viewport” content=”width=device-width,user-scalable=no” />
Example: 2. Set the screen density to high frequency, medium frequency, low frequency automatic scaling, prohibit the user from manual adjustment Zoom
<meta name=”viewport” content=”width=device-width,target-densitydpi=high-dpi,initial-scale=1.0
【Related recommendations】
1. Special recommendation:"php programmer toolbox" V0. 1 version download
2. Example code about viewport compatibility issues
3. viewport special topic: in-depth understanding of responsive web design in css -viewport
The above is the detailed content of Introduction to the parameters of Viewport in HTML5 and how to use it. For more information, please follow other related articles on the PHP Chinese website!

PHP5.4版本新功能:如何使用callable类型提示参数接受可调用的函数或方法引言:PHP5.4版本引入了一项非常便利的新功能-可以使用callable类型提示参数来接受可调用的函数或方法。这个新功能使得函数和方法可以直接指定相应的可调用参数,而无需进行额外的检查和转换。在本文中,我们将介绍callable类型提示的使用方法,并提供一些代码示例,

产品参数是指产品属性的意思。比如服装参数有品牌、材质、型号、大小、风格、面料、适应人群和颜色等;食品参数有品牌、重量、材质、卫生许可证号、适应人群和颜色等;家电参数有品牌、尺寸、颜色、产地、适应电压、信号、接口和功率等。

在开发过程中,我们可能会遇到这样一个错误提示:PHPWarning:in_array()expectsparameter。这个错误提示会在使用in_array()函数时出现,有可能是因为函数的参数传递不正确所导致的。以下我们来看看这个错误提示的解决方法。首先,需要明确in_array()函数的作用:检查一个值是否在数组中存在。该函数的原型为:in_a

双曲函数是使用双曲线而不是圆定义的,与普通三角函数相当。它从提供的弧度角返回双曲正弦函数中的比率参数。但要做相反的事,或者换句话说。如果我们想根据双曲正弦值计算角度,我们需要像双曲反正弦运算一样的反双曲三角运算。本课程将演示如何使用C++中的双曲反正弦(asinh)函数,使用双曲正弦值(以弧度为单位)计算角度。双曲反正弦运算遵循以下公式-$$\mathrm{sinh^{-1}x\:=\:In(x\:+\:\sqrt{x^2\:+\:1})},其中\:In\:是\:自然对数\:(log_e\:k)

ML中的一个重要任务是模型选择,或者使用数据为给定任务找到最佳的模型或参数。这也称为调优。可以对单个的估计器(如LogisticRegression)进行调优,也可以对包括多种算法、特性化和其他步骤的整个pipeline进行调优。用户可以一次调优整个Pipeline,而不是分别调优 Pipeline 中的每个元素。ML中的一个重要任务是模型选择,或者使用数据为给定任务找到最佳的模型或参数。这也称为调优。可以对单个的Estimator(如LogisticRegression)进行调优,也

大型语言模型(LLM)虽然性能强劲,但动辄几百上千亿的参数量,对计算设备还是内存的需求量之大,都不是一般公司能承受得住的。量化(Quantization)是常见的压缩操作,通过降低模型权重的精度(如32bit降为8bit),牺牲一部分模型的性能来换取更快的推理速度,更少的内存需求。但对于超过1000亿参数量的LLM来说,现有的压缩方法都无法保持模型的准确率,也无法在硬件上高效地运行。最近,麻省理工学院和英伟达的研究人员联合提出了一个通用后训练的量化(GPQ, general-purpose po

CSSViewport:如何使用vh、vw、vmin和vmax单位来实现响应式设计,需要具体代码示例在现代响应式网页设计中,我们通常希望网页能够适应不同屏幕尺寸和设备,以提供良好的用户体验。而CSSViewport单位(视口单位)就是帮助我们实现这一目标的重要工具之一。在本文中,我们将介绍如何使用vh、vw、vmin和vmax单位来实现响应式设

如何使用CSSViewport单位vh来创建适配手机屏幕的网页布局手机设备的普及和使用越来越广泛,越来越多的网页需要进行手机屏幕的适配。为了解决这个问题,CSS3引入了一个新的单位——Viewport单位,其中包括vh(viewportheight)。在这篇文章中,我们将探讨如何使用vh单位来创建适配手机屏幕的网页布局,并提供具体的代码示例。一


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

SublimeText3 Linux new version
SublimeText3 Linux latest version

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool