1.viewport
能优化移动浏览器的显示。如果不是响应式网站,不要使用initial-scale或者禁用缩放。
大部分4.7-5寸设备的viewport宽设为360px;5.5寸设备设为400px;iphone6设为375px;ipone6 plus设为414px。
//表示支持响应式设计
width:控制 viewport 的大小,可以指定的一个值,如果 600,或者特殊的值,如 device-width 为设备的宽度(单位为缩放为 100% 时的 CSS 的像素)。
height:和 width 相对应,指定高度。
initial-scale:初始缩放比例,也即是当页面第一次 load 的时候缩放比例。
maximum-scale:允许用户缩放到的最大比例。
minimum-scale:允许用户缩放到的最小比例。
user-scalable:用户是否可以手动缩放(user-scalable=no//user-scalable=0,不允许用户手动缩放)
注意:content里多个属性的设置一定要用逗号+空格来隔开,如果不规范将不会起作用
WebApp全屏模式:伪装app,离线应用
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"apple-mobile-web-app-capable" <span class="hljs-attribute">content=<span class="hljs-value">"yes" /> //<span class="hljs-comment">启用 WebApp 全屏模式</span></span></span></span></span></span>
隐藏状态栏/设置状态栏颜色:只有在开启WebApp全屏模式时才生效。content的值为default | black | black-translucent
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"apple-mobile-web-app-status-bar-style" <span class="hljs-attribute">content=<span class="hljs-value">"black-translucent" /></span></span></span></span></span>
添加到主屏后的标题
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"apple-mobile-web-app-title" <span class="hljs-attribute">content=<span class="hljs-value">"标题"></span></span></span></span></span>
忽略数字自动识别为电话号码
<span class="hljs-tag">meta <span class="hljs-attribute">content=<span class="hljs-value">"telephone=no" <span class="hljs-attribute">name=<span class="hljs-value">"format-detection" /></span></span></span></span></span>
忽略识别邮箱
<span class="hljs-tag">meta <span class="hljs-attribute">content=<span class="hljs-value">"email=no" <span class="hljs-attribute">name=<span class="hljs-value">"format-detection" />
</span></span></span></span></span>
添加智能 App 广告条 Smart App Banner:告诉浏览器这个网站对应的app,并在页面上显示下载banner
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"apple-itunes-app" <span class="hljs-attribute">content=<span class="hljs-value">"app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL"></span></span></span></span></span>
<span class="hljs-comment"><!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 --></span>
<span class="hljs-comment"><span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"HandheldFriendly" <span class="hljs-attribute">content=<span class="hljs-value">"true">
</span></span></span></span></span></span>
<span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><!-- 微软的老式浏览器 -->
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"MobileOptimized" <span class="hljs-attribute">content=<span class="hljs-value">"320">
</span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><!-- uc强制竖屏 -->
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"screen-orientation" <span class="hljs-attribute">content=<span class="hljs-value">"portrait">
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><!-- QQ强制竖屏 -->
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"x5-orientation" <span class="hljs-attribute">content=<span class="hljs-value">"portrait">
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><!-- UC强制全屏 -->
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"full-screen" <span class="hljs-attribute">content=<span class="hljs-value">"yes">
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><!-- QQ强制全屏 -->
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"x5-fullscreen" <span class="hljs-attribute">content=<span class="hljs-value">"true">
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><!-- UC应用模式 -->
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"browsermode" <span class="hljs-attribute">content=<span class="hljs-value">"application"></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><!-- QQ应用模式 -->
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"x5-page-mode" <span class="hljs-attribute">content=<span class="hljs-value">"app">
</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
<span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><span class="hljs-tag"><span class="hljs-title"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-attribute"><span class="hljs-value"><span class="hljs-comment"><!-- windows phone 点击无高光 -->
<span class="hljs-tag">meta <span class="hljs-attribute">name=<span class="hljs-value">"msapplication-tap-highlight" <span class="hljs-attribute">content=<span class="hljs-value">"no"></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>
网页相关
- 申明编码
<code><span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">charset=<span class="hljs-value">'utf-8' /> </span></span></span></span></code>
- 优先使用 IE 最新版本和 Chrome
<code><span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">http-equiv=<span class="hljs-value">"X-UA-Compatible" <span class="hljs-attribute">content=<span class="hljs-value">"IE=edge,chrome=1" /> <span class="hljs-comment"><!-- 关于X-UA-Compatible --> <span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">http-equiv=<span class="hljs-value">"X-UA-Compatible" <span class="hljs-attribute">content=<span class="hljs-value">"IE=6" ><span class="hljs-comment"><!-- 使用IE6 --> <span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">http-equiv=<span class="hljs-value">"X-UA-Compatible" <span class="hljs-attribute">content=<span class="hljs-value">"IE=7" ><span class="hljs-comment"><!-- 使用IE7 --> <span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">http-equiv=<span class="hljs-value">"X-UA-Compatible" <span class="hljs-attribute">content=<span class="hljs-value">"IE=8" ><span class="hljs-comment"><!-- 使用IE8 --> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></code>
- 浏览器内核控制:国内浏览器很多都是双内核(webkit和Trident),webkit内核高速浏览,IE内核兼容网页和旧版网站。而添加meta标签的网站可以控制浏览器选择何种内核渲染。
<code> <span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">name=<span class="hljs-value">"renderer" <span class="hljs-attribute">content=<span class="hljs-value">"webkit|ie-comp|ie-stand"> </span></span></span></span></span></span></code>
国内双核浏览器默认内核模式如下:
1. 搜狗高速浏览器、QQ浏览器:IE内核(兼容模式)
2. 360极速浏览器、遨游浏览器:Webkit内核(极速模式)
- 禁止浏览器从本地计算机的缓存中访问页面内容:这样设定,访问者将无法脱机浏览。
<code><span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">http-equiv=<span class="hljs-value">"Pragma" <span class="hljs-attribute">content=<span class="hljs-value">"no-cache"> </span></span></span></span></span></span></code>
- Windows 8
<code><span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">name=<span class="hljs-value">"msapplication-TileColor" <span class="hljs-attribute">content=<span class="hljs-value">"#000"/> <span class="hljs-comment"><!-- Windows 8 磁贴颜色 --> <span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">name=<span class="hljs-value">"msapplication-TileImage" <span class="hljs-attribute">content=<span class="hljs-value">"icon.png"/> <span class="hljs-comment"><!-- Windows 8 磁贴图标 --> </span></span></span></span></span></span></span></span></span></span></span></span></span></span></code>
- 站点适配:主要用于PC-手机页的对应关系。
<code><span class="hljs-tag"><<span class="hljs-title">meta <span class="hljs-attribute">name=<span class="hljs-value">"mobile-agent"<span class="hljs-value">content="format=[wml|xhtml|html5]; <span class="hljs-attribute">url=<span class="hljs-value">url"> <span class="hljs-comment"><!-- [wml|xhtml|html5]根据手机页的协议语言,选择其中一种; url="url" 后者代表当前PC页所对应的手机页URL,两者必须是一一对应关系。 --> </span></span></span></span></span></span></span></span></code>
- 转码申明:用百度打开网页可能会对其进行转码(比如贴广告),避免转码可添加如下meta
<code><<span class="hljs-title">meta <span class="hljs-attribute">http-equiv=<span class="hljs-value">"Cache-Control" <span class="hljs-attribute">content=<span class="hljs-value">"no-siteapp" /><br /></span></span></span></span></span></code>
2.Content-Type和Content-Language (显示字符集的设定)
说明:设定页面使用的字符集,用以说明主页制作所使用的文字已经语言,浏览器会根据此来调用相应的字符集显示page内容。
用法:

The official account web page update cache, this thing is simple and simple, and it is complicated enough to drink a pot of it. You worked hard to update the official account article, but the user still opened the old version. Who can bear the taste? In this article, let’s take a look at the twists and turns behind this and how to solve this problem gracefully. After reading it, you can easily deal with various caching problems, allowing your users to always experience the freshest content. Let’s talk about the basics first. To put it bluntly, in order to improve access speed, the browser or server stores some static resources (such as pictures, CSS, JS) or page content. Next time you access it, you can directly retrieve it from the cache without having to download it again, and it is naturally fast. But this thing is also a double-edged sword. The new version is online,

This article demonstrates efficient PNG border addition to webpages using CSS. It argues that CSS offers superior performance compared to JavaScript or libraries, detailing how to adjust border width, style, and color for subtle or prominent effect

The article discusses the HTML <datalist> element, which enhances forms by providing autocomplete suggestions, improving user experience and reducing errors.Character count: 159

The article discusses using HTML5 form validation attributes like required, pattern, min, max, and length limits to validate user input directly in the browser.

Article discusses best practices for ensuring HTML5 cross-browser compatibility, focusing on feature detection, progressive enhancement, and testing methods.

The article discusses the HTML <progress> element, its purpose, styling, and differences from the <meter> element. The main focus is on using <progress> for task completion and <meter> for stati

The article discusses the HTML <meter> element, used for displaying scalar or fractional values within a range, and its common applications in web development. It differentiates <meter> from <progress> and ex

This article explains the HTML5 <time> element for semantic date/time representation. It emphasizes the importance of the datetime attribute for machine readability (ISO 8601 format) alongside human-readable text, boosting accessibilit


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

Zend Studio 13.0.1
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

Atom editor mac version download
The most popular open source editor

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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.
