css - 用于移动应用程序的 HTML5 全局元标记/样式

标签 css html styles meta

我是一名 C++ 开发人员,最近开始在我的移动应用程序中使用 HTML5,我对网络编程领域的了解不多,我非常希望获得一些建议以微调我的元标记。

我需要适合 ios/android/windows phone/blackberry 等移动应用程序的完美元标记。

问题是我不确定我到底需要什么和不需要什么,这是我目前的列表:

html, body
{
     overflow: hidden;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    -khtml-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-overflow-scrolling: none;
    -webkit-backface-visibility: hidden;
    -webkit-transition: translate3d(0,0,0);

    transition: translate3d(0,0,0);

    -webkit-font-smoothing: antialiased;
    font-smoothing: antialiased;
    text-shadow: 1px 1px 1px rgba(0,0,0,0.004);
    -webkit-text-stroke: 1px

    -webkit-user-select: none; /* Chrome/Safari */        
    -moz-user-select: none; /* Firefox */
    -ms-user-select: none; /* IE10+ */

    /* Rules below not implemented in browsers yet */
    -o-user-select: none;
    user-select: none;

    margin: 0;
    padding: 0;
    border: 0;

    background-color:#202020;
}

* {margin:0; padding:0; border:0;}

<!DOCTYPE html>
<html>
    <head>
        <title>$Title</title>

        <meta charset="UTF-8">
        <meta name="keywords" content="Test">
        <meta name="description" content="Test">
        <meta name="subject" content="Test">
        <meta name="copyright" content="Test">
        <meta name="url" content="http://www.test.com">
        <meta name="language" content="en-GB">
        <meta name="robots" content="NOINDEX, NOFOLLOW">
        <meta name="pagename" content="$Title">
        <meta name="coverage" content="Worldwide">
        <meta name="distribution" content="Global">
        <meta name="target" content="all">
        <meta name="HandheldFriendly" content="True">
        <meta name="MobileOptimized" content="640">
        <meta name="format-detection" content="telephone=no">
        <meta http-equiv="cleartype" content="on">
        <meta name="apple-mobile-web-app-title" content="$Title">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-touch-fullscreen" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="ResourceLoaderDynamicStyles" content="">
        <meta http-equiv="Expires" content="0">
        <meta http-equiv="Pragma" content="no-cache">
        <meta http-equiv="Cache-Control" content="no-cache">
        <meta http-equiv="imagetoolbar" content="no">
        <meta http-equiv="x-dns-prefetch-control" content="off">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

        <meta http-equiv="X-UA-Compatible" content="IE=9; IE=8;" />

        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no">

        <!-- Makes your prototype chrome-less once bookmarked to your phone's home screen -->
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">

        <!-- Set a shorter title for iOS6 devices when saved to home screen -->
        <meta name="apple-mobile-web-app-title" content="Ratchet">

        <script>
        document.ontouchmove = function(e)
        {
            e.preventDefault();
        }
        </script>

有什么建议吗?

最佳答案

你需要:

<meta charset="UTF-8">
<title></title>
<meta name="description" content="Test">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">

- user-scalable=no"这将阻止缩放您的应用,我建议不要使用(糟糕的用户体验)

<meta name="apple-mobile-web-app-title" content="$Title"> 

- 如果您不想为此使用标题标签,则启动器标题。

<meta name="apple-mobile-web-app-capable" content="yes"> 

- 这将隐藏浏览器界面

<meta name="apple-mobile-web-app-status-bar-style" content="black">

- 这将改变 ios 中状态栏的颜色


你应该添加:

<link rel="apple-touch-icon" href="apple-touch-icon-iphone.png">
<link rel="apple-touch-icon" sizes="76x76" href="touch-icon-ipad.png">
<link rel="apple-touch-icon" sizes="120x120" href="touch-icon-iphone-retina.png">
<link rel="apple-touch-icon" sizes="152x152" href="touch-icon-ipad-retina.png">

-iOS 启动器图标

<meta name="msapplication-TileImage" content="icon.png">
<meta name="msapplication-TileColor" content="#222222">

- Windows 图标

<link rel="apple-touch-startup-image" href="/startup-image.png">

-iOs 启动图像

<meta name="mobile-web-app-capable" content="yes">

- Android/Chrome 主屏幕


你不需要:

<meta name="keywords" content="Test"> 

- 不需要这个,google 和其他搜索引擎不使用关键字 meta

<meta name="subject" content="Test">

- 页面的主题。不推荐

<meta name="copyright" content="Test">

- 给你的比给别人的多

 <meta name="url" content="http://www.test.com">

- 这是您的完整域名或网址。搜索引擎优化

<meta name="language" content="en-GB">

- W3C 推荐使用 <html lang="en">不是元标记

<meta name="pagename" content="$Title">

- 这是额外的页面标题。 html5 规范中没有这样的标签吗?

<meta name="coverage" content="Worldwide">
<meta name="distribution" content="Global">

- 定义爬虫的分布级别或程度,但没有可识别的元数据,那么您不应该使用它们。对 HTML5 无效

 <meta name="target" content="all"> 

- ???不确定它是什么:P 一些疯狂的 window 东西旧旧的? html5 规范中没有这样的标签吗?

<meta name="HandheldFriendly" content="True">

- 旧 Windows 手机的 future 会说该页面可以在小屏幕上查看

<meta name="MobileOptimized" content="640">

- 关于针对 Windows 优化的屏幕页面大小的声明,但它是针对旧手机的,它并没有真正起作用。我建议为此使用媒体查询。

 <meta name="format-detection" content="telephone=no">

- iOS 上 Safari 的电话号码检测(如果禁用此功能,用户体验会很差)

<meta http-equiv="cleartype" content="on">

- 移动 IE 平滑字体功能,但这不是标准的 W3C 标签。我建议在 CSS 中进行字体平滑处理。

<meta name="apple-touch-fullscreen" content="yes">

- 这在早期的演示中使用过。你只需要 <meta name="apple-mobile-web-app-capable" content="yes">

<meta name="ResourceLoaderDynamicStyles" content="">

- 这应该让浏览器在添加 CSS 之前标记 DOM。我认为你不应该那样做。

<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-Control" content="no-cache">

- 缓存东西。现在这种事情是在服务器端完成的。

<meta http-equiv="imagetoolbar" content="no">

- IE6 特性。显然不需要

<meta http-equiv="x-dns-prefetch-control" content="off">

- DNS 预取。

<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/> 

- IE8/9 兼容模式。

<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

- 重复条目 <meta charset="UTF-8">

   <!-- Makes your prototype chrome-less once bookmarked to your phone's home screen -->
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <!-- Set a shorter title for iOS6 devices when saved to home screen -->
    <meta name="apple-mobile-web-app-title" content="Ratchet">

- 重复条目

关于css - 用于移动应用程序的 HTML5 全局元标记/样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24662220/

相关文章:

html - 垂直居中 div - 浏览器兼容性

h1 中的 CSS 跨度填充和背景

javascript - 从 div 中获取值的脚本,比较它是否是时间值,然后添加它

html - 如何使用纯 css 自动调整图像大小以进行响应式设计?

html - 更改焦点选择输入的边框颜色

html - 如何触发点击组件中的 HTML 文件元素? ( Angular 2)

javascript - 基本正则表达式问题

css - 在 Zend 中设置主体类

css - 如何使一个 div 具有与另一个相同的样式但名称不同?

子项的 WPF/XAML 样式集属性?