<?xml version="1.0" standalone="yes"?>
<?xml-stylesheet type="text/xsl" href="css/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>郑州网建 - Html_Css</title><link>http://camnpr.com/</link><description>Good Good Study ,Day Day Up! - </description><generator>RainbowSoft Studio Z-Blog 1.8 Walle Build 100427</generator><language>zh-CN</language><copyright>豫ICP备10013645号 Copyright 2009-2022 camnpr.com</copyright><pubDate>Thu, 23 Apr 2026 03:22:21 +0800</pubDate><item><title>解决Web移动端Fixed布局的方案（防止页面露底、overflow-scrolling、iOS下的 Fixed + Input BUG现象、isScroll.js）</title><author>raodaor@163.com (raodaor)</author><link>http://camnpr.com/html-css/2263.html</link><pubDate>Tue, 24 May 2016 16:00:23 +0800</pubDate><guid>http://camnpr.com/html-css/2263.html</guid><description><![CDATA[<h3 id="其他的一些细节处理">一些细节处理</h3><p>在细节处理上，其实还有很多要注意的，挑几个实际遇到比较大的问题来说一下：</p><ol>    <li>有时候输入框 focus 以后，会出现软键盘遮挡输入框的情况，这时候可以尝试 input 元素的 scrollIntoView 进行修复。</li>    <li>在 iOS 下使用第三方输入法时，输入法在唤起经常会盖住输入框，只有在输入了一条文字后，输入框才会浮出。目前也不知道有什么好的办法能让唤起输入框时正确显示。这暂时算是 iOS 下的一个坑吧。</li>    <li>有些第三方浏览器底部的工具栏是浮在页面之上的，因此底部 fixed 定位会被工具栏遮挡。解决办法也比较简单粗暴&mdash;&mdash;适配不同的浏览器，调整 fixed 元素距离底部的距离。</li>    <li>最好将 header 和 footer 元素的 touchmove 事件禁止，以防止滚动在上面触发了部分浏览器全屏模式切换，而导致顶部地址栏和底部工具栏遮挡住 header 和 footer 元素。</li>    <li>    <p>在页面滚动到上下边缘的时候，如果继续拖拽会将整个 View 一起拖拽走，导致页面的&ldquo;露底&rdquo;。</p>    <div class="figure"><img title="fixed page" src="http://camnpr.com/upload/2016/5/201605241849185435.png" alt="fixed定位" />    <p class="caption">fixed定位</p>    </div>    </li></ol><p>为了防止页面露底，可以在页面拖拽到边缘的时候，通过判断拖拽方向以及是否为边缘来阻止 touchmove 事件，防止页面继续拖拽。</p><p>以上面内滚动 <code>layout-scroll-fixed</code> 布局为例，给出一段代码作为参考：</p><pre class="brush:js">// 防止内容区域滚到底后引起页面整体的滚动<br />var content = document.querySelector('main');<br />var startY;<br />content.addEventListener('touchstart', function (e) {<br />&nbsp; &nbsp; startY = e.touches[0].clientY;<br />});<br /><br />content.addEventListener('touchmove', function (e) {<br />&nbsp; &nbsp; // 高位表示向上滚动<br />&nbsp; &nbsp; // 底位表示向下滚动<br />&nbsp; &nbsp; // 1容许 0禁止<br />&nbsp; &nbsp; var status = '11';<br />&nbsp; &nbsp; var ele = this;<br /><br />&nbsp; &nbsp; var currentY = e.touches[0].clientY;<br /><br />&nbsp; &nbsp; if (ele.scrollTop === 0) {<br />&nbsp; &nbsp; &nbsp; &nbsp; // 如果内容小于容器则同时禁止上下滚动<br />&nbsp; &nbsp; &nbsp; &nbsp; status = ele.offsetHeight &gt;= ele.scrollHeight ? '00' : '01';<br />&nbsp; &nbsp; } else if (ele.scrollTop + ele.offsetHeight &gt;= ele.scrollHeight) {<br />&nbsp; &nbsp; &nbsp; &nbsp;// 已经滚到底部了只能向上滚动<br />&nbsp; &nbsp; &nbsp; &nbsp;status = '10';<br />&nbsp; &nbsp; }<p>&nbsp;</p><br />&nbsp; &nbsp; if (status != '11') {<br />&nbsp; &nbsp; &nbsp; &nbsp; // 判断当前的滚动方向<br />&nbsp; &nbsp; &nbsp; &nbsp; var direction = currentY - startY &gt; 0 ? '10' : '01';<br />&nbsp; &nbsp; &nbsp; &nbsp; // 操作方向和当前允许状态求与运算，运算结果为0，就说明不允许该方向滚动，则禁止默认事件，阻止滚动<br />&nbsp; &nbsp; &nbsp; &nbsp; if (!(parseInt(status, 2) &amp; parseInt(direction, 2))) {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; stopEvent(e);<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; }<br />});</pre><p>&nbsp;</p><p>移动端业务开发，iOS 下经常会有 fixed 元素和输入框(input 元素)同时存在的情况。 但是 fixed 元素在有软键盘唤起的情况下，会出现许多莫名其妙的问题。 这篇文章里就提供一个简单的有输入框情况下的 fixed 布局方案。</p><hr /><h3 id="ios下的-fixed-input-bug现象">iOS下的 Fixed + Input BUG现象</h3><p>让我们先举个栗子，最直观的说明一下这个 BUG 的现象。 常规的 fixed 布局，可能使用如下布局（以下仅示意代码）：</p><p><figure class="highlight html"><table>    <tbody>        <tr>            <td class="code">            <pre><span class="line"><span class="tag">&lt;<span class="title">body</span> <span class="attribute">class</span>=<span class="value">&quot;layout-fixed&quot;</span>&gt;</span></span><br /><span class="line">    <span class="comment">&lt;!-- fixed定位的头部 --&gt;</span></span><br /><span class="line">    <span class="tag">&lt;<span class="title">header</span>&gt;</span></span><br />        <br /><span class="line">    <span class="tag">&lt;/<span class="title">header</span>&gt;</span></span><br />    <br /><span class="line">    <span class="comment">&lt;!-- 可以滚动的区域 --&gt;</span></span><br /><span class="line">    <span class="tag">&lt;<span class="title">main</span>&gt;</span></span><br /><span class="line">        <span class="comment">&lt;!-- 内容在这里... --&gt;</span></span><br /><span class="line">    <span class="tag">&lt;/<span class="title">main</span>&gt;</span></span><br />    <br /><span class="line">    <span class="comment">&lt;!-- fixed定位的底部 --&gt;</span></span><br /><span class="line">    <span class="tag">&lt;<span class="title">footer</span>&gt;</span></span><br /><span class="line">        <span class="tag">&lt;<span class="title">input</span> <span class="attribute">type</span>=<span class="value">&quot;text&quot;</span> <span class="attribute">placeholder</span>=<span class="value">&quot;Footer...&quot;</span>/&gt;</span></span><br /><span class="line">        <span class="tag">&lt;<span class="title">button</span> <span class="attribute">class</span>=<span class="value">&quot;submit&quot;</span>&gt;</span>提交<span class="tag">&lt;/<span class="title">button</span>&gt;</span></span><br /><span class="line">    <span class="tag">&lt;/<span class="title">footer</span>&gt;</span></span><br /><span class="line"><span class="tag">&lt;/<span class="title">body</span>&gt;</span></span></pre>            </td>        </tr>    </tbody></table></figure></p><p>对应的样式如下：</p><p><figure class="highlight css"><table>    <tbody>        <tr>            <td class="code">            <pre><span class="line"><span class="tag">header</span>, <span class="tag">footer</span>, <span class="tag">main</span> <span class="rules">{</span><br /><span class="line">    <span class="rule"><span class="attribute">display</span>:<span class="value"> block</span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span><br /><br /><span class="line"><span class="tag">header</span> <span class="rules">{</span><br /><span class="line">    <span class="rule"><span class="attribute">position</span>:<span class="value"> fixed</span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">height</span>:<span class="value"> <span class="number">50px</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">left</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">right</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">top</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span><br /><br /><span class="line"><span class="tag">footer</span> <span class="rules">{</span><br /><span class="line">    <span class="rule"><span class="attribute">position</span>:<span class="value"> fixed</span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">height</span>:<span class="value"> <span class="number">34px</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">left</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">right</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">bottom</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span><br /><br /><span class="line"><span class="tag">main</span> <span class="rules">{</span><br /><span class="line">    <span class="rule"><span class="attribute">margin-top</span>:<span class="value"> <span class="number">50px</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">margin-bottom</span>:<span class="value"> <span class="number">34px</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">height</span>:<span class="value"> <span class="number">2000px</span></span><br /></span></span>}</span></pre>            </td>        </tr>    </tbody></table></figure></p><p>然后看起来就是下面这个样子。拖动页面时 header 和 footer 已经定位在了对应的位置，目测没问题了。</p><div class="figure"><img title="fixed page" src="http://camnpr.com/upload/2016/5/201605241849214042.png" alt="fixed定位" /><p class="caption">fixed定位</p></div><p>但接下来问题就来了！如果底部输入框软键盘被唤起以后，再次滑动页面，就会看到如下图所示：</p><p><img title="fixed page" src="http://camnpr.com/upload/2016/5/201605241849228314.png" alt="fixed定位" /> <img title="fixed page" src="http://camnpr.com/upload/2016/5/201605241849224483.png" alt="fixed定位" /></p><p>我们看到 fixed 定位好的元素跟随页面滚动了起来&hellip; fixed 属性失效了！</p><p>这是为什么呢？简单解释下： &gt; <strong>软键盘唤起后，页面的 fixed 元素将失效（即无法浮动，也可以理解为变成了 absolute 定位），所以当页面超过一屏且滚动时，失效的 fixed 元素就会跟随滚动了。</strong></p><p>这便是 iOS 上 fixed 元素和输入框的 bug 。其中不仅限于 <code>type=text</code> 的输入框，凡是软键盘（比如时间日期选择、select 选择等等）被唤起，都会遇到同样地问题。</p><hr /><p>虽然 <code>isScroll.js</code> 可以很好的解决 fixed 定位滚动的问题，但是不在万不得已的情况下，我们尽量尝试一下不依赖第三方库的布局方案，以简化实现方式。这里抛砖引玉作为参考。</p><h3 id="解决思路">解决思路：</h3><p>既然在 iOS 下由于软键盘唤出后，页面 fixed 元素会失效，导致跟随页面一起滚动，那么<strong>假如&mdash;&mdash;页面不会过长出现滚动，那么即便 fixed 元素失效，也无法跟随页面滚动，也就不会出现上面的问题了</strong>。</p><p>那么按照这个思路，如果使 fixed 元素的父级不出现滚动，而将原 body 滚动的区域域移到 main 内部，而 header 和 footer 的样式不变，代码如下：</p><p><figure class="highlight html"><table>    <tbody>        <tr>            <td class="code">            <pre><span class="line"><span class="tag">&lt;<span class="title">body</span> <span class="attribute">class</span>=<span class="value">&quot;layout-scroll-fixed&quot;</span>&gt;</span></span><br /><span class="line">    <span class="comment">&lt;!-- fixed定位的头部 --&gt;</span></span><br /><span class="line">    <span class="tag">&lt;<span class="title">header</span>&gt;</span></span><br />        <br /><span class="line">    <span class="tag">&lt;/<span class="title">header</span>&gt;</span></span><br />    <br /><span class="line">    <span class="comment">&lt;!-- 可以滚动的区域 --&gt;</span></span><br /><span class="line">    <span class="tag">&lt;<span class="title">main</span>&gt;</span></span><br /><span class="line">        <span class="tag">&lt;<span class="title">div</span> <span class="attribute">class</span>=<span class="value">&quot;content&quot;</span>&gt;</span></span><br /><span class="line">        <span class="comment">&lt;!-- 内容在这里... --&gt;</span></span><br /><span class="line">        <span class="tag">&lt;/<span class="title">div</span>&gt;</span></span><br /><span class="line">    <span class="tag">&lt;/<span class="title">main</span>&gt;</span></span><br />    <br /><span class="line">    <span class="comment">&lt;!-- fixed定位的底部 --&gt;</span></span><br /><span class="line">    <span class="tag">&lt;<span class="title">footer</span>&gt;</span></span><br /><span class="line">        <span class="tag">&lt;<span class="title">input</span> <span class="attribute">type</span>=<span class="value">&quot;text&quot;</span> <span class="attribute">placeholder</span>=<span class="value">&quot;Footer...&quot;</span>/&gt;</span></span><br /><span class="line">        <span class="tag">&lt;<span class="title">button</span> <span class="attribute">class</span>=<span class="value">&quot;submit&quot;</span>&gt;</span>提交<span class="tag">&lt;/<span class="title">button</span>&gt;</span></span><br /><span class="line">    <span class="tag">&lt;/<span class="title">footer</span>&gt;</span></span><br /><span class="line"><span class="tag">&lt;/<span class="title">body</span>&gt;</span></span></pre>            </td>        </tr>    </tbody></table></figure> <figure class="highlight css"><table>    <tbody>        <tr>            <td class="code">            <pre><span class="line"><span class="tag">header</span>, <span class="tag">footer</span>, <span class="tag">main</span> <span class="rules">{</span><br /><span class="line">    <span class="rule"><span class="attribute">display</span>:<span class="value"> block</span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span><br /><br /><span class="line"><span class="tag">header</span> <span class="rules">{</span><br /><span class="line">    <span class="rule"><span class="attribute">position</span>:<span class="value"> fixed</span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">height</span>:<span class="value"> <span class="number">50px</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">left</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">right</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">top</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span><br /><br /><span class="line"><span class="tag">footer</span> <span class="rules">{</span><br /><span class="line">    <span class="rule"><span class="attribute">position</span>:<span class="value"> fixed</span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">height</span>:<span class="value"> <span class="number">34px</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">left</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">right</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">bottom</span>:<span class="value"> <span class="number">0</span></span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span><br /><br /><span class="line"><span class="tag">main</span> <span class="rules">{</span><br /><span class="line">    <span class="comment">/* main绝对定位，进行内部滚动 */</span></span><br /><span class="line">    <span class="rule"><span class="attribute">position</span>:<span class="value"> absolute</span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">top</span>:<span class="value"> <span class="number">50px</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">bottom</span>:<span class="value"> <span class="number">34px</span></span></span>;</span><br /><span class="line">    <span class="comment">/* 使之可以滚动 */</span></span><br /><span class="line">    <span class="rule"><span class="attribute">overflow-y</span>:<span class="value"> scroll</span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span><br /><br /><span class="line"><span class="tag">main</span> <span class="class">.content</span> <span class="rules">{</span><br /><span class="line">    <span class="rule"><span class="attribute">height</span>:<span class="value"> <span class="number">2000px</span></span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span></pre>            </td>        </tr>    </tbody></table></figure></p><p>这样再来看一下：</p><div class="figure"><img title="fixed page" src="http://camnpr.com/upload/2016/5/201605241849223631.png" alt="fixed定位" /><p class="caption">fixed定位</p></div><p>在原始输入法下， fixed 元素可以定位在页面的正确位置。滚动页面时，由于滚动的是 main 内部的 div，因此 footer 没有跟随页面滚动。</p><p>上面貌似解决了问题，但是如果在手机上实际测试一下，会发现 main 元素内的滚动非常不流畅，滑动的手指松开后，滚动立刻停止，失去了原本的流畅滚动特性。百度一下弹性滚动的问题，发现在 <code>webkit</code> 中，下面的属性可以恢复弹性滚动。</p><blockquote><p>-webkit-overflow-scrolling: touch;</p></blockquote><p>在 main 元素上加上该属性，嗯，丝般顺滑的感觉又回来了！</p><p><figure class="highlight css"><table>    <tbody>        <tr>            <td class="code">            <pre><span class="line"><span class="tag">main</span> <span class="rules">{</span><br /><span class="line">    <span class="comment">/* main绝对定位，进行内部滚动 */</span></span><br /><span class="line">    <span class="rule"><span class="attribute">position</span>:<span class="value"> absolute</span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">top</span>:<span class="value"> <span class="number">50px</span></span></span>;</span><br /><span class="line">    <span class="rule"><span class="attribute">bottom</span>:<span class="value"> <span class="number">34px</span></span></span>;</span><br /><span class="line">    <span class="comment">/* 使之可以滚动 */</span></span><br /><span class="line">    <span class="rule"><span class="attribute">overflow-y</span>:<span class="value"> scroll</span></span>;</span><br /><span class="line">    <span class="comment">/* 增加该属性，可以增加弹性 */</span></span><br /><span class="line">    <span class="rule"><span class="attribute">-webkit-overflow-scrolling</span>:<span class="value"> touch</span></span>;</span><br /><span class="line"><span class="rule">}</span></span></span></pre>            </td>        </tr>    </tbody></table></figure></p><p>另外，这里的 header 和 footer 使用的是 fixed 定位，如果考虑到更老一些的 iOS 系统不支持 fixed 元素，完全可以把 fixed 替换成 absolute 。测试后效果是一样的。</p><p>至此一个不依赖第三方库的 fixed 布局就完成了。</p><hr /><h3 id="android-下布局">Android 下布局</h3><p>谈到了 iOS ，也来简单说一下 Android 下的布局吧。</p><p>在 Android2.3+ 中，因为不支持 overflow-scrolling ，因此部分浏览器内滚动会有不流畅的卡顿。但是目前发现在 body 上的滚动还是很流畅的，因此使用第一种在 iOS 出现问题的 fixed 定位的布局就可以了。</p><p>如果需要考虑 Android2.3 以下系统，因为不支持 fixed 元素，所以依然要需要考虑使用 <code>isScroll.js</code> 来实现内部滚动。</p><p>其实在 fixed 和输入框的问题上，基本思路就是： &gt; 由于 fixed 在软键盘唤起后会失效，导致在页面可以滚动时，会跟随页面一起滚动。因此如果页面无法滚动，那么 fixed 元素即使失效，也不会滚动，也就不会出现 bug 了。</p><p>所以可以在这个方面去考虑解决问题。</p>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2263.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2263</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2263&amp;key=ea3df443</trackback:ping></item><item><title>解决&amp;amp;#65279导致页面顶部空白一行方法 UTF-8 + BOM</title><author>bubuol@126.com (llmaomi)</author><link>http://camnpr.com/html-css/2262.html</link><pubDate>Fri, 29 Apr 2016 15:37:01 +0800</pubDate><guid>http://camnpr.com/html-css/2262.html</guid><description><![CDATA[<p>模板文件生成html文件之后会在body开头处加入一个可见的控制符﻿，导致页面头部会出现一个空白行。原因是页面的编码是UTF-8 + BOM。</p><p>这种编码方式一般会在windows操作系统中出现，比如WINDOWS自带的记事本等软件，在保存一个以UTF-8编码的文件时，会在文件开始的地方插入三个不可见的字符（0xEF 0xBB 0xBF，即BOM）。它是一串隐藏的字符，用于让记事本等编辑器识别这个文件是否以UTF-8编码。</p><p>对于一般的文件，这样并不会产生什么麻烦。但对于 PHP来说，BOM是个大麻烦。因为PHP并不会忽略BOM，所以在读取、包含或者引用这些文件时，会把BOM作为该文件开头正文的一部分。根据嵌入式语言的特点，这串字符将被直接执行（显示）出来。由此造成即使页面的 top padding 设置为0，也无法让整个网页紧贴浏览器顶部，因为在html一开头有这3个隐藏字符﻿！</p><p>遇到这种问题的解决方法就是用<strong>Editplus </strong>2.12版本以上编辑器或者 <strong>EmEditor</strong>或者 <strong>UltraEdit</strong>（需要取消&lsquo;添加BOM&rsquo;的相关选项）或者 <strong>Dreamweaver</strong>（需要取消&lsquo;添加BOM&rsquo;的相关选项）重新保存一下utf-8格式的文档！</p>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2262.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2262</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2262&amp;key=19f3ab10</trackback:ping></item><item><title>响应式布局@media only screen and 设备像素比率（-webkit-min-device-pixel-ratio）</title><author>camnpr@163.com (佚名)</author><link>http://camnpr.com/html-css/2256.html</link><pubDate>Sat, 27 Feb 2016 09:58:49 +0800</pubDate><guid>http://camnpr.com/html-css/2256.html</guid><description><![CDATA[<div><h2>常见屏幕参数</h2><ul>    <li>设备 分辨率 设备像素比率</li>    <li>Android LDPI 320&times;240 0.75</li>    <li>Iphone 3 &amp; Android MDPI 320&times;480 1</li>    <li>Android HDPI 480&times;800 1.5</li>    <li>Iphone 4 960&times;640 2.0</li></ul><p>iPhone 4的一个 CSS 像素实际上表现为一块 2&times;2 的像素。所以图片像是被放大2倍一样，模糊不清晰。</p><p>解决办法：</p><p>1、页面引用</p><pre>&lt;link rel=&quot;stylesheet&quot; media=&quot;screen and (-webkit-device-pixel-ratio: 0.75)&quot; href=&quot;ldpi.css&quot; /&gt;<br />&lt;link rel=&quot;stylesheet&quot; media=&quot;screen and (-webkit-device-pixel-ratio: 1.0)&quot; href=&quot;mdpi.css&quot; /&gt;<br />&lt;link rel=&quot;stylesheet&quot; media=&quot;screen and (-webkit-device-pixel-ratio: 1.5)&quot; href=&quot;hdpi.css&quot; /&gt;<br />&lt;link rel=&quot;stylesheet&quot; media=&quot;screen and (-webkit-device-pixel-ratio: 2.0)&quot; href=&quot;retina.css&quot; /&gt;<br /></pre><p>2、CSS文件里</p><pre>#header {<br />    background:url(mdpi/bg.png);<br />}<br /><br />@media screen and (-webkit-device-pixel-ratio: 1.5) {<br />    /*CSS for high-density screens*/<br />    #header {<br />        background:url(hdpi/bg.png);<br />    }<br />}</pre></div><div><span style="color: #ff0000; font-size: large;" data-mce-style="color: #ff0000; font-size: large;"><strong><span style="font-family: verdana, Arial, Helvetica, sans-serif;" data-mce-style="font-family: verdana, Arial, Helvetica, sans-serif;">@media only screen and&nbsp;</span></strong></span></div><div><strong>only</strong>(限定某种设备)</div><div><strong><span style="color: #ff00ff;" data-mce-style="color: #ff00ff;">screen</span></strong>&nbsp;是媒体类型里的一种</div><div><strong>and</strong>&nbsp;被称为关键字，其他关键字还包括&nbsp;<strong>not</strong>(排除某种设备)</div><div><p><span style="color: #808080;" data-mce-style="color: #808080;">/* 常用类型 */</span><br />类型 解释<br />all 所有设备<br />braille 盲文<br />embossed 盲文打印<br />handheld 手持设备<br />print 文档打印或打印预览模式<br />projection 项目演示，比如幻灯<br />screen 彩色电脑屏幕<br />speech 演讲<br />tty 固定字母间距的网格的媒体，比如电传打字机<br />tv 电视</p><p><span style="color: #ff00ff;" data-mce-style="color: #ff00ff;">screen</span>一般用的比较多，下面是我自己的尝试，列出常用的设备的尺寸，然后给页面分了几个尺寸的版本。</p><p><span style="color: #808080;" data-mce-style="color: #808080;">/* 常用设备 */</span><br />设备 屏幕尺寸<br />显示器 1280 x 800<br />ipad 1024 x 768<br />Android 800 x 480<br />iPhone 640 x 960</p></div><p><span style="color: #ff0000; font-size: large;" data-mce-style="color: #ff0000; font-size: large;"><strong>两种方式</strong></span><wbr></wbr></p><div><span style="font-size: large;" data-mce-style="font-size: large;">a</span>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;styleB.css&quot; media=&quot;screen and (min-width: 600px) and (max-width: 800px)&quot;&gt;</div><div>意思是当屏幕的宽度大于600小于800时，应用styleB.css</div><div><span style="font-size: large;" data-mce-style="font-size: large;"><strong>b</strong></span>@media screen and (max-width: 600px) { /*当屏幕尺寸小于600px时，应用下面的CSS样式*/</div><pre>  .class {    background: #ccc;  }}</pre><p>&nbsp;</p><div><h3><span style="color: #ff0000;" data-mce-style="color: #ff0000;">device-aspect-ratio</span></h3></div><div>device-aspect-ratio可以用来适配特定屏幕长宽比的设备，这也是一个很有用的属性，比如，我们的页面想要对长宽比为4:3的普通屏幕定义一种样式，然后对于16:9和16:10的宽屏，定义另一种样式，比如自适应宽度和固定宽度：</div><div><pre>@media only screen and (device-aspect-ratio:4/3)</pre><pre><strong>-webkit-min-device-pixel-ratio的常见值对比<span style="color: #808080;" data-mce-style="color: #808080;">（</span></strong><span style="color: #808080;" data-mce-style="color: #808080;">是设备上物理像素和设备独立像素，<span style="font-size: large;" data-mce-style="font-size: large;">设备像素比率</span><span style="font-family: Tahoma; font-size: large;" data-mce-style="font-family: Tahoma; font-size: large;"><strong>）</strong></span></span></pre><table class="mce-item-table">    <thead>        <tr>            <td width="200">设备</td>            <td width="100">分辨率</td>            <td width="150">设备像素比率</td>        </tr>    </thead>    <tbody>        <tr>            <td>Android LDPI</td>            <td>320&times;240</td>            <td>0.75</td>        </tr>        <tr>            <td>Iphone 3 &amp; Android MDPI</td>            <td>320&times;480</td>            <td>1</td>        </tr>        <tr>            <td>Android HDPI</td>            <td>480&times;800</td>            <td>1.5</td>        </tr>        <tr>            <td>Iphone 4</td>            <td>960&times;640</td>            <td>2.0</td>        </tr>    </tbody></table><pre>&nbsp;</pre><p><strong>&nbsp;&nbsp;&nbsp;&nbsp; -webkit-min-device-pixel-ratio: 1.0</strong></p><ul>    <li>所有非 Retina 的 Mac</li>    <li>所有非&nbsp;Retina 的 iOS 设备</li>    <li>Acer Iconia A500</li>    <li>Samsung Galaxy Tab 10.1</li>    <li>Samsung Galaxy S</li>    <li>其他设备</li></ul><ul>    <li>-webkit-min-device-pixel-ratio为1.3</li></ul><ol>    <li>Google Nexus 7</li></ol><ul>    <li>-webkit-min-device-pixel-ratio为1.5</li></ul><ol>    <li>Google Nexus S&nbsp;</li>    <li>Samsung Galaxy S II&nbsp;</li>    <li>HTC Desire</li>    <li>HTC Desire HD</li>    <li>HTC Incredible S&nbsp;</li>    <li>HTC Velocity</li>    <li>HTC Sensation&nbsp;</li></ol><ul>    <li>-webkit-min-device-pixel-ratio为2.0</li></ul><ol>    <li>iPhone 4</li>    <li>iPhone 4S</li>    <li>iPhone 5</li>    <li>iPad (3rd generation)</li>    <li>iPad 4</li>    <li>所有Retina displays 的MAC</li>    <li>Google Galaxy Nexus</li>    <li>Google Nexus 4</li>    <li>Google Nexus 10</li>    <li>Samsung Galaxy S III</li>    <li>Samsung Galaxy Note II</li>    <li>Sony Xperia S</li>    <li>HTC One X&nbsp;</li></ol><p><strong>-webkit-min-device-pixel-ratio: 3.0</strong></p>&nbsp;&nbsp; 1.HTC Butterfly<br />&nbsp;&nbsp; 2.Sony Xperia S<p>&nbsp;</p></div><p><span style="color: #ff0000; font-size: large;" data-mce-style="color: #ff0000; font-size: large;"><strong>(min-resolution:144dpi)</strong></span><br />&lt;resolution&gt;（分辨率）&nbsp;</p><dl><dt>使用于：位图媒体类型,接受max/min前缀：</dt></dl><p>&ldquo;<code>resolution</code>&rdquo;媒体特性描述输出设备的分辨率，例如，像素密度。若查询设备的非方形像素，在&ldquo;<code>min-resolution</code>&rdquo;查询中指定的值必须与最稀疏尺寸进行比较，在&ldquo;<code>max-resolution</code>&rdquo;查询中必须与最密集尺寸进行比较。对于&ldquo;<code>resolution</code>&rdquo;（没有&ldquo;min-&rdquo;或&ldquo;max-&rdquo;前缀）查询从不查询设备的非方形像素。</p><p>对于印刷机，相当于分辨率（任意颜色的绘制点的分辨率）。</p><pre>举例说明：该媒体查询表示样式表适用于分辨率大于每英寸<span style="font-size: small;" data-mce-style="font-size: small;">144</span>点的设备：<span style="color: #ff00ff;" data-mce-style="color: #ff00ff;">@media print and (min-resolution: <span style="font-size: small;" data-mce-style="font-size: small;">144</span>dpi) { &hellip; }</span></pre>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2256.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2256</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2256&amp;key=ec2e7c0b</trackback:ping></item><item><title>汇总30条移动Web开发技巧【看过都觉得：老有用了】</title><author>camnpr@163.com (佚名)</author><link>http://camnpr.com/html-css/2183.html</link><pubDate>Thu, 29 Oct 2015 10:49:51 +0800</pubDate><guid>http://camnpr.com/html-css/2183.html</guid><description><![CDATA[<div id="noimgcss"><p>1. 添加到主屏后的标题（IOS）<br />2. 启用 WebApp 全屏模式（IOS）<br />3. 百度禁止转码<br />4. 设置状态栏的背景颜色（IOS）<br />5. 移动端手机号码识别（IOS）<br />6. 移动端邮箱识别（Android）<br />7. 添加智能 App 广告条 Smart App Banner（IOS 6+ Safari）<br />8. IOS Web app启动动画<br />9. 添加到主屏后的APP图标<br />10. 优先使用最新版本 IE 和 Chrome<br />11.viewport模板<br />1、移动端如何定义字体font-family<br />2、移动端字体单位font-size选择px还是rem<br />3、移动端touch事件(区分webkit 和 winphone)<br />4、移动端click屏幕产生200-300 ms的延迟响应<br />5、什么是Retina 显示屏，带来了什么问题<br />6、ios系统中元素被触摸时产生的半透明灰色遮罩怎么去掉<br />7、部分android系统中元素被点击时产生的边框怎么去掉<br />8、winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉<br />9、webkit表单元素的默认外观怎么重置<br />10、webkit表单输入框placeholder的颜色值能改变么<br />11、webkit表单输入框placeholder的文字能换行么<br />12. 关闭iOS键盘首字母自动大写<br />13. 关闭iOS输入自动修正<br />14. 禁止文本缩放<br />15. 移动端如何清除输入框内阴影<br />16. 快速回弹滚动<br />17. 移动端禁止选中内容<br />18. 移动端取消touch高亮效果<br />19. 如何禁止保存或拷贝图像（IOS）<br />20.模拟按钮hover效果<br />21.屏幕旋转的事件和样式<br />22.audio元素和video元素在ios和andriod中无法自动播放<br />23.摇一摇功能<br />24.手机拍照和上传图片<br />25. 消除transition闪屏<br />26. android 上去掉语音输入按钮<br />1. 移动端基础框架<br />2. 滑屏框架<br />3.瀑布流框架</p><h2>META相关</h2><h4>1. 添加到主屏后的标题（IOS）</h4><pre class="brush:js">&lt;meta name=&quot;apple-mobile-web-app-title&quot; content=&quot;标题&quot;&gt; </pre><h4>2. 启用 WebApp 全屏模式（IOS）</h4><p>当网站添加到主屏幕后再点击进行启动时，可隐藏地址栏（从浏览器跳转或输入链接进入并没有此效果）</p><pre class="brush:js">&lt;meta name=&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot; /&gt; <br />&lt;meta name=&quot;apple-touch-fullscreen&quot; content=&quot;yes&quot; /&gt; </pre><p>&lt;!--more--&gt;</p><h4>3. 百度禁止转码</h4><p>通过百度手机打开网页时，百度可能会对你的网页进行转码，往你页面贴上它的广告，非常之恶心。不过我们可以通过这个meta标签来禁止它：</p><pre class="brush:js">&lt;meta http-equiv=&quot;Cache-Control&quot; content=&quot;no-siteapp&quot; /&gt;</pre><p><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fm%7Cbaidu%7Ccom%2Fpub%2Fhelp%7Cphp%3Fpn%3D22%26amp%3Bssid%3D0%26amp%3Bfrom%3D844b%26amp%3Bbd_page_type%3D1" target="_blank">百度SiteApp转码声明</a></p><h4>4. 设置状态栏的背景颜色（IOS）</h4><p>设置状态栏的背景颜色，只有在&nbsp;&quot;apple-mobile-web-app-capable&quot; content=&quot;yes&quot;&nbsp;时生效</p><pre class="brush:js">&lt;meta name=&quot;apple-mobile-web-app-status-bar-style&quot; content=&quot;black-translucent&quot; /&gt; </pre><p>content 参数：</p><ul>    <li>default ：状态栏背景是白色。</li>    <li>black ：状态栏背景是黑色。</li>    <li>black-translucent ：状态栏背景是半透明。 如果设置为 default 或 black ,网页内容从状态栏底部开始。 如果设置为 black-translucent ,网页内容充满整个屏幕，顶部会被状态栏遮挡。</li></ul><h4>5. 移动端手机号码识别（IOS）</h4><p>在 iOS Safari （其他浏览器和Android均不会）上会对那些看起来像是电话号码的数字处理为电话链接，比如：</p><ul>    <li>7位数字，形如：1234567</li>    <li>带括号及加号的数字，形如：(+86)123456789</li>    <li>双连接线的数字，形如：00-00-00111</li>    <li>11位数字，形如：13800138000</li></ul><p><strong>可能还有其他类型的数字也会被识别。我们可以通过如下的meta来关闭电话号码的自动识别：</strong></p><pre class="brush:js">&lt;meta name=&quot;format-detection&quot; content=&quot;telephone=no&quot; /&gt;</pre><p><strong>开启电话功能</strong></p><pre class="brush:js">&lt;a href=&quot;tel:123456&quot;&gt;<span class="token number">123456&lt;/a&gt;</span></pre><p><strong>开启短信功能：</strong></p><pre class="brush:js">&lt;a href=&quot;sms:123456&quot;&gt;<span class="token number">123456&lt;/a&gt; </span></pre><h4>6. 移动端邮箱识别（Android）</h4><p>与电话号码的识别一样，在安卓上会对符合邮箱格式的字符串进行识别，我们可以通过如下的meta来管别邮箱的自动识别：</p><pre class="brush:js">&lt;meta content=&quot;email=no&quot; name=&quot;format-detection&quot; /&gt; </pre><p>同样地，我们也可以通过标签属性来开启长按邮箱地址弹出邮件发送的功能：</p><pre class="brush:js">&lt;a mailto:dooyoe@gmail.com&quot;&gt;dooyoe@gmail.com&lt;/a&gt; </pre><h4>7. 添加智能 App 广告条 Smart App Banner（IOS 6+ Safari）</h4><pre class="brush:js">&lt;meta name=&quot;apple-itunes-app&quot; content=&quot;app-id=myAppStoreID, affiliate-data=myAffiliateData, app-argument=myURL&quot;&gt;</pre><h4>8. IOS Web app启动动画</h4><p>由于iPad 的启动画面是不包括状态栏区域的。所以启动图片需要减去状态栏区域所对应的方向上的20px大小，相应地在retina设备上要减去40px的大小</p><pre class="brush:js">&lt;!-- iPhone --&gt;<br />&lt;link href=&quot;apple-touch-startup-image-320x460.png&quot; media=&quot;(device-width: 320px)&quot; rel=&quot;apple-touch-startup-image&quot;&gt;<br />&lt;!-- iPhone (Retina) --&gt;<br />&lt;link href=&quot;apple-touch-startup-image-640x960.png&quot; media=&quot;(device-width: 320px) and (-webkit-device-pixel-ratio: 2)&quot; rel=&quot;apple-touch-startup-image&quot;&gt;<br />&lt;!-- iPad (portrait) --&gt;<br />&lt;link href=&quot;apple-touch-startup-image-768x1004.png&quot; media=&quot;(device-width: 768px) and (orientation: portrait)&quot; rel=&quot;apple-touch-startup-image&quot;&gt;<br />&lt;!-- iPad (landscape) --&gt;<br />&lt;link href=&quot;apple-touch-startup-image-748x1024.png&quot; media=&quot;(device-width: 768px) and (orientation: landscape)&quot; rel=&quot;apple-touch-startup-image&quot;&gt;<br />&lt;!-- iPad (Retina, portrait) --&gt;<br />&lt;link href=&quot;apple-touch-startup-image-1536x2008.png&quot; media=&quot;(device-width: 1536px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)&quot; rel=&quot;apple-touch-startup-image&quot;&gt;<br />&lt;!-- iPad (Retina, landscape) --&gt;<br />&lt;link href=&quot;apple-touch-startup-image-2048x1496.png&quot; media=&quot;(device-width: 1536px)  and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)&quot; rel=&quot;apple-touch-startup-image&quot;&gt;</pre><p>（landscape：横屏&nbsp;| portrait：竖屏）</p><h4>9. 添加到主屏后的APP图标</h4><p>指定web app添加到主屏后的图标路径，有两种略微不同的方式：</p><pre class="brush:js">&lt;!-- 设计原图 --&gt;<br />&lt;link href=&quot;short_cut_114x114.png&quot; rel=&quot;apple-touch-icon-precomposed&quot;&gt;<br />&lt;!-- 添加高光效果 --&gt;<br />&lt;link href=&quot;short_cut_114x114.png&quot; rel=&quot;apple-touch-icon&quot;&gt;</pre><p>* apple-touch-icon：在IOS6及以下的版本会自动为图标添加一层高光效果（IOS7开始已使用扁平化的设计风格） * apple-touch-icon-precomposed：使用&ldquo;设计原图图标&rdquo;</p><p><em>效果：</em></p><p><img title="" src="http://camnpr.com/upload/2015/10/201510281453065375.png" alt="" /></p><p><strong>图标尺寸：</strong></p><p>可通过指定size属性来为不同的设备提供不同的图标（但通常来说，我们只需提供一个114 x 114 pixels大小的图标即可 ）</p><p><em>官方说明如下</em></p><pre class="brush:js">Create different sizes of your app icon for different devices. If you&rsquo;re creating a universal app, you need to supply app icons in all four sizes.For iPhone and iPod touch both of these sizes are required:<span class="token number">57 x <span class="token number">57 pixels<span class="token number">114 x <span class="token number">114 pixels (high resolution)For iPad, both of these sizes are required:<span class="token number">72 x <span class="token number">72 pixels<span class="token number">144 x <span class="token number">144 (high resolution)</span></span></span></span></span></span></span></span></pre><h4>10. 优先使用最新版本 IE 和 Chrome</h4><pre class="brush:js">&lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge,chrome=1&quot; /&gt; </pre><h4>11.viewport模板</h4><pre class="brush:js">&lt;!DOCTYPE html&gt;<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;meta charset=&quot;utf-8&quot;&gt;<br />&lt;meta content=&quot;width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no&quot; name=&quot;viewport&quot;&gt;<br />&lt;meta content=&quot;yes&quot; name=&quot;apple-mobile-web-app-capable&quot;&gt;<br />&lt;meta content=&quot;black&quot; name=&quot;apple-mobile-web-app-status-bar-style&quot;&gt;<br />&lt;meta content=&quot;telephone=no&quot; name=&quot;format-detection&quot;&gt;<br />&lt;meta content=&quot;email=no&quot; name=&quot;format-detection&quot;&gt;<br />&lt;title&gt;标题&lt;/title&gt;<br />&lt;link rel=&quot;stylesheet&quot; href=&quot;index.css&quot;&gt;<br />&lt;/head&gt;<br />&lt;body&gt;这里开始内容&lt;/body&gt;<br />&lt;/html&gt;</pre><h2>常见问题</h2><h4>1、移动端如何定义字体font-family</h4><p>三大手机系统的字体：</p><p><strong><em>ios 系统</em></strong></p><ul>    <li>默认中文字体是Heiti SC</li>    <li>默认英文字体是Helvetica</li>    <li>默认数字字体是HelveticaNeue</li>    <li>无微软雅黑字体</li></ul><p><strong><em>android 系统</em></strong></p><ul>    <li>默认中文字体是Droidsansfallback</li>    <li>默认英文和数字字体是Droid Sans</li>    <li>无微软雅黑字体</li></ul><p><strong><em>winphone 系统</em></strong></p><ul>    <li>默认中文字体是Dengxian(方正等线体)</li>    <li>默认英文和数字字体是Segoe</li>    <li>无微软雅黑字体</li></ul><p>各个手机系统有自己的默认字体，且都不支持微软雅黑 如无特殊需求，手机端无需定义中文字体，使用系统默认 英文字体和数字字体可使用 Helvetica ，三种系统都支持</p><pre class="brush:js">/* 移动端定义字体的代码 */<br />body{font-family:Helvetica;}</pre><h4>2、移动端字体单位font-size选择px还是rem</h4><p>对于只需要适配手机设备，使用px即可</p><p>对于需要适配各种移动设备，使用rem，例如只需要适配iPhone和iPad等分辨率差别比较挺大的设备</p><p>rem配置参考：</p><pre class="brush:js">html {font-size:10px}<br />@media screen and (min-width:480px) and (max-width:639px) {    <br />    html {<br />        font-size: 15px<br />    }<br />}<br />@media screen and (min-width:640px) and (max-width:719px) {<br />    html {<br />        font-size: 20px<br />    }<br />}<br />@media screen and (min-width:720px) and (max-width:749px) {<br />    html {<br />        font-size: <span class="token number">22.5px<br />    }<br />}<br />@media screen and (min-width:750px) and (max-width:799px) {<br />    html {<br />        font-size: <span class="token number">23.5px<br />    }<br />}<br />@media screen and (min-width:800px) and (max-width:959px) {<br />    html {<br />        font-size: 25px<br />    }<br />}<br />@media screen and (min-width:960px) and (max-width:1079px) {<br />    html {<br />        font-size: 30px<br />    }<br />}<br />@media screen and (min-width:1080px) {<br />    html {<br />        font-size: 32px<br />    }<br />}</span></span></pre><h4>3、移动端touch事件(区分webkit 和 winphone)</h4><p>当用户手指放在移动设备在屏幕上滑动会触发的touch事件</p><p><strong><em>以下支持webkit</em></strong></p><ul>    <li>touchstart&mdash;&mdash;当手指触碰屏幕时候发生。不管当前有多少只手指</li>    <li>touchmove&mdash;&mdash;当手指在屏幕上滑动时连续触发。通常我们再滑屏页面，会调用event的preventDefault()可以阻止默认情况的发生：阻止页面滚动</li>    <li>touchend&mdash;&mdash;当手指离开屏幕时触发</li>    <li>touchcancel&mdash;&mdash;系统停止跟踪触摸时候会触发。例如在触摸过程中突然页面alert()一个提示框，此时会触发该事件，这个事件比较少用</li></ul><p><strong><em>以下支持winphone 8</em></strong></p><ul>    <li>MSPointerDown&mdash;&mdash;当手指触碰屏幕时候发生。不管当前有多少只手指</li>    <li>MSPointerMove&mdash;&mdash;当手指在屏幕上滑动时连续触发。通常我们再滑屏页面，会调用css的html{-ms-touch-action: none;}可以阻止默认情况的发生：阻止页面滚动</li>    <li>MSPointerUp&mdash;&mdash;当手指离开屏幕时触发</li></ul><h4>4、移动端click屏幕产生200-300 ms的延迟响应</h4><p>移动设备上的web网页是有300ms延迟的，玩玩会造成按钮点击延迟甚至是点击失效。</p><p>以下是历史原因：</p><p>2007年苹果发布首款iphone上IOS系统搭载的safari为了将适用于PC端上大屏幕的网页能比较好的展示在手机端上，使用了双击缩放(double tap to zoom)的方案，比如你在手机上用浏览器打开一个PC上的网页，你可能在看到页面内容虽然可以撑满整个屏幕，但是字体、图片都很小看不清，此时可以快速双击屏幕上的某一部分，你就能看清该部分放大后的内容，再次双击后能回到原始状态。</p><p>双击缩放是指用手指在屏幕上快速点击两次，iOS 自带的 Safari 浏览器会将网页缩放至原始比例。</p><p>原因就出在浏览器需要如何判断快速点击上，当用户在屏幕上单击某一个元素时候，例如跳转链接&lt;a href=&quot;#&quot;&gt;&lt;/a&gt;，此处浏览器会先捕获该次单击，但浏览器不能决定用户是单纯要点击链接还是要双击该部分区域进行缩放操作，所以，捕获第一次单击后，浏览器会先Hold一段时间t，如果在t时间区间里用户未进行下一次点击，则浏览器会做单击跳转链接的处理，如果t时间里用户进行了第二次单击操作，则浏览器会禁止跳转，转而进行对该部分区域页面的缩放操作。那么这个时间区间t有多少呢？在IOS safari下，大概为300毫秒。这就是延迟的由来。造成的后果用户纯粹单击页面，页面需要过一段时间才响应，给用户慢体验感觉，对于web开发者来说是，页面js捕获click事件的回调函数处理，需要300ms后才生效，也就间接导致影响其他业务逻辑的处理。</p><p><strong>解决方案：</strong></p><ul>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=https%3A%2F%2Fgithub%7Ccom%2Fftlabs%2Ffastclick" target="_blank">fastclick</a>可以解决在手机上点击事件的300ms延迟</li>    <li>zepto的touch模块，tap事件也是为了解决在click的延迟问题</li></ul><p><strong>触摸事件的响应顺序</strong></p><pre class="brush:js"><span class="token number">1、ontouchstart <br /><span class="token number">2、ontouchmove <br /><span class="token number">3、ontouchend <br /><span class="token number">4、onclick</span></span></span></span></pre><p>解决300ms延迟的问题，也可以通过绑定ontouchstart事件，加快对事件的响应</p><h4>5、什么是Retina 显示屏，带来了什么问题</h4><p>retina：一种具备超高像素密度的液晶屏，同样大小的屏幕上显示的像素点由1个变为多个，如在同样带下的屏幕上，苹果设备的retina显示屏中，像素点1个变为4个</p><p>在高清显示屏中的位图被放大，图片会变得模糊，因此移动端的视觉稿通常会设计为传统PC的<span class="token number">2倍</span></p><p>那么，前端的应对方案是：</p><p>设计稿切出来的图片长宽保证为偶数，并使用backgroud-size把图片缩小为原来的1/2</p><pre class="brush:js"><br />//例如图片宽高为：200px*200px，那么写法如下<br />.css{width:100px;height:100px;background-size:100px 100px;}</pre><p>其它元素的取值为原来的1/2，例如视觉稿40px的字体，使用样式的写法为20px</p><pre class="brush:js">.css{font-size:20px}</pre><h4>6、ios系统中元素被触摸时产生的半透明灰色遮罩怎么去掉</h4><p>ios用户点击一个链接，会出现一个半透明灰色遮罩, 如果想要禁用，可设置-webkit-tap-highlight-color的alpha值为0，也就是属性值的最后一位设置为0就可以去除半透明灰色遮罩</p><pre class="brush:js">a,button,input,textarea{-webkit-tap-highlight-color: <span class="token function">rgba(<span class="token number">0,<span class="token number">0,<span class="token number">0,<span class="token number">0;)}</span></span></span></span></span></pre><h4>7、部分android系统中元素被点击时产生的边框怎么去掉</h4><p>android用户点击一个链接，会出现一个边框或者半透明灰色遮罩, 不同生产商定义出来额效果不一样，可设置-webkit-tap-highlight-color的alpha值为0去除部分机器自带的效果</p><pre class="brush:js">a,button,input,textarea{<br />    -webkit-tap-highlight-color: <span class="token function">rgba(<span class="token number">0,<span class="token number">0,<span class="token number">0,<span class="token number">0;)<br />    -webkit-user-modify:read-write-plaintext-only;<br /> }</span></span></span></span></span></pre><p><em>-webkit-user-modify有个副作用，就是输入法不再能够输入多个字符</em></p><p>另外，有些机型去除不了，如小米2</p><p>对于按钮类还有个办法，不使用a或者input标签，直接用div标签</p><h4>8、winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉</h4><pre class="brush:js">&lt;meta name=&quot;msapplication-tap-highlight&quot; content=&quot;no&quot;&gt;</pre><h4>9、webkit表单元素的默认外观怎么重置</h4><pre class="brush:js">.css{-webkit-appearance:none;}</pre><h4>10、webkit表单输入框placeholder的颜色值能改变么</h4><pre class="brush:js">input::-webkit-input-placeholder{color:#AAAAAA;}<br />input:focus::-webkit-input-placeholder{color:#EEEEEE;}</pre><h4>11、webkit表单输入框placeholder的文字能换行么</h4><p><em>ios可以，android不行~</em></p><h4>12. 关闭iOS键盘首字母自动大写</h4><p>在iOS中，默认情况下键盘是开启首字母大写的功能的，如果启用这个功能，可以这样：</p><pre class="brush:js">&lt;input type=&quot;text&quot; autocapitalize=&quot;off&quot; /&gt;</pre><h4>13. 关闭iOS输入自动修正</h4><p>和英文输入默认自动首字母大写那样，IOS还做了一个功能，默认输入法会开启自动修正输入内容，这样的话，用户经常要操作两次。如果不希望开启此功能，我们可以通过input标签属性来关闭掉：</p><pre class="brush:js">&lt;input type=&quot;text&quot; autocorrect=&quot;off&quot; /&gt; </pre><h4>14. 禁止文本缩放</h4><p>当移动设备横竖屏切换时，文本的大小会重新计算，进行相应的缩放，当我们不需要这种情况时，可以选择禁止：</p><pre class="brush:js">html {<br />　　      -webkit-text-size-adjust: <span class="token number">100%;<br />}</span></pre><p>需要注意的是，PC端的该属性已经被移除，该属性在移动端要生效，必须设置 &lsquo;meta viewport&rsquo;。</p><h4>15. 移动端如何清除输入框内阴影</h4><p>在iOS上，输入框默认有内部阴影，但无法使用 box-shadow 来清除，如果不需要阴影，可以这样关闭：</p><pre class="brush:js">input,textarea {<br />　　border: <span class="token number">0; /* 方法1 */<br />　　-webkit-appearance: none; /* 方法2 */<br />}</span></pre><h4>16. 快速回弹滚动</h4><p>我们先来看看回弹滚动在手机浏览器发展的历史：</p><ul>    <li>早期的时候，移动端的浏览器都不支持非body元素的滚动条，所以一般都借助 iScroll;</li>    <li>Android 3.0/iOS解决了非body元素的滚动问题，但滚动条不可见，同时iOS上只能通过2个手指进行滚动；</li>    <li>Android 4.0解决了滚动条不可见及增加了快速回弹滚动效果，不过随后这个特性又被移除；</li>    <li>iOS从5.0开始解决了滚动条不可见及增加了快速回弹滚动效果</li></ul><p>在iOS上如果你想让一个元素拥有像 Native 的滚动效果，你可以这样做：</p><pre class="brush:js">    .xxx {<br />        overflow: auto; /* auto | scroll */<br />        -webkit-overflow-scrolling: touch;<br />    }</pre><p><em>PS：iScroll用过之后感觉不是很好，有一些诡异的bug，这里推荐另外一个 iDangero Swiper，这个插件集成了滑屏滚动的强大功能（支持3D），而且还有回弹滚动的内置滚动条，官方地址：</em></p><p><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fwww%7Cidangero%7Cus%2Fsliders%2Fswiper%2Findex%7Cphp" target="_blank">iDangero</a></p><h4>17. 移动端禁止选中内容</h4><p>如果你不想用户可以选中页面中的内容，那么你可以在css中禁掉：</p><pre class="brush:js">.user-select-none {<br />  -webkit-user-select: none;  /* Chrome all / Safari all */<br />  -moz-user-select: none;     /* Firefox all （移动端不需要） */<br />  -ms-user-select: none;      /* IE 10+ */      }</pre><h4>18. 移动端取消touch高亮效果</h4><p>在做移动端页面时，会发现所有a标签在触发点击时或者所有设置了伪类 :active 的元素，默认都会在激活状态时，显示高亮框，如果不想要这个高亮，那么你可以通过css以下方法来进行全局的禁止：</p><pre class="brush:js">html {<br />    -webkit-tap-highlight-color: <span class="token function">rgba(<span class="token number">0, <span class="token number">0, <span class="token number">0, <span class="token number">0);<br />}</span></span></span></span></span></pre><p>但这个方法在三星的机子上无效，有一种妥协的方法是把页面非真实跳转链接的a标签换成其它标签，可以解决这个问题。</p><h4>19. 如何禁止保存或拷贝图像（IOS）</h4><p>通常当你在手机或者pad上长按图像 img ，会弹出选项 存储图像 或者 拷贝图像，如果你不想让用户这么操作，那么你可以通过以下方法来禁止：</p><pre class="brush:js">img {<br /> -webkit-touch-callout: none;<br /> }</pre><h4>20.模拟按钮hover效果</h4><p>移动端触摸按钮的效果，可明示用户有些事情正要发生，是一个比较好体验，但是移动设备中并没有鼠标指针，使用css的hover并不能满足我们的需求，还好国外有个激活css的active效果，代码如下，</p><pre class="brush:js">&lt;!DOCTYPE html&gt;<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;meta charset=&quot;utf-8&quot;&gt;<br />&lt;meta content=&quot;width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no&quot; name=&quot;viewport&quot;&gt;<br />&lt;meta content=&quot;yes&quot; name=&quot;apple-mobile-web-app-capable&quot;&gt;<br />&lt;meta content=&quot;black&quot; name=&quot;apple-mobile-web-app-status-bar-style&quot;&gt;<br />&lt;meta content=&quot;telephone=no&quot; name=&quot;format-detection&quot;&gt;<br />&lt;meta content=&quot;email=no&quot; name=&quot;format-detection&quot;&gt;<br />&lt;style type=&quot;text/css&quot;&gt;<br />a{-webkit-tap-highlight-color: <span class="token function">rgba(<span class="token number">0,<span class="token number">0,<span class="token number">0,<span class="token number">0);}<br />.btn-blue{display:block;height:42px;line-height:42px;text-align:center;border-radius:4px;font-size:18px;color:#FFFFFF;background-color: #4185F3;}<br />.btn-blue:active{background-color: #357AE8;}&lt;/style&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;div class=&quot;btn-blue&quot;&gt;按钮&lt;/div&gt;<br />&lt;script type=&quot;text/javascript&quot;&gt;document.<span class="token function">addEventListener(&quot;touchstart&quot;, function(){}, <span class="token boolean">true)&lt;/script&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</span></span></span></span></span></span></span></pre><p>兼容性ios5+、部分android 4+、winphone 8</p><p>要做到全兼容的办法，可通过绑定ontouchstart和ontouchend来控制按钮的类名</p><pre class="brush:js">&lt;!DOCTYPE html&gt;<br />&lt;html&gt;<br />&lt;head&gt;<br />&lt;meta charset=&quot;utf-8&quot;&gt;<br />&lt;meta content=&quot;width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no&quot; name=&quot;viewport&quot;&gt;<br />&lt;meta content=&quot;yes&quot; name=&quot;apple-mobile-web-app-capable&quot;&gt;<br />&lt;meta content=&quot;black&quot; name=&quot;apple-mobile-web-app-status-bar-style&quot;&gt;<br />&lt;meta content=&quot;telephone=no&quot; name=&quot;format-detection&quot;&gt;<br />&lt;meta content=&quot;email=no&quot; name=&quot;format-detection&quot;&gt;<br />&lt;style type=&quot;text/css&quot;&gt;<br />a{-webkit-tap-highlight-color: <span class="token function">rgba(<span class="token number">0,<span class="token number">0,<span class="token number">0,<span class="token number">0);}<br />.btn-blue{display:block;height:42px;line-height:42px;text-align:center;border-radius:4px;font-size:18px;color:#FFFFFF;background-color: #4185F3;}<br />.btn-blue-on{background-color: #357AE8;}<br />&lt;/style&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;div class=&quot;btn-blue&quot;&gt;按钮&lt;/div&gt;<br />&lt;script type=&quot;text/javascript&quot;&gt;<br />var btnBlue = document.<span class="token function">querySelector(&quot;.btn-blue&quot;);<br />btnBlue.ontouchstart = function(){<br />    this.className = &quot;btn-blue btn-blue-on&quot;<br />}<br />btnBlue.ontouchend = function(){<br />    this.className = &quot;btn-blue&quot;<br />}<br />&lt;/script&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</span></span></span></span></span></span></pre><h4>21.屏幕旋转的事件和样式</h4><p><strong>事件</strong></p><p>window.orientation，取值：正负90表示横屏模式、0和180表现为竖屏模式；</p><pre class="brush:js">window.onorientationchange = function(){<br />            <span class="token function">switch(window.orientation){<br />                case -<span class="token number">90:<br />                case <span class="token number">90:<br />                <span class="token function">alert(&quot;横屏:&quot; + window.orientation);<br />                case <span class="token number">0:<br />                case <span class="token number">180:<br />                <span class="token function">alert(&quot;竖屏:&quot; + window.orientation);<br />                break;<br />            }<br />} </span></span></span></span></span></span></span></pre><p><strong>样式</strong></p><pre class="brush:js"><br />//竖屏时使用的样式<br />@media all and (orientation:portrait) {<br />    .css{}<br />}<br />//横屏时使用的样式<br />@media all and (orientation:landscape) {<br />    .css{}<br />}</pre><h4>22.audio元素和video元素在ios和andriod中无法自动播放</h4><p>应对方案：触屏即播</p><pre class="brush:js">$('html').<span class="token function">one('touchstart',function(){<br />    audio.<span class="token function">play()<br />})</span></span></pre><h4>23.摇一摇功能</h4><p>HTML5 deviceMotion：封装了运动传感器数据的事件，可以获取手机运动状态下的运动加速度等数据。</p><h4>24.手机拍照和上传图片</h4><p>&lt;input type=&quot;file&quot;&gt;的accept 属性</p><pre class="brush:js">&lt;!-- 选择照片 --&gt;<br />&lt;input type=file accept=&quot;image/*&quot;&gt;<br />&lt;!-- 选择视频 --&gt;<br />&lt;input type=file accept=&quot;video/*&quot;&gt;</pre><p>使用总结：</p><ul>    <li>ios 有拍照、录像、选取本地图片功能</li>    <li>部分android只有选取本地图片功能</li>    <li>winphone不支持</li>    <li>input控件默认外观丑陋</li></ul><h4>25. 消除transition闪屏</h4><pre class="brush:js">.css{    <br />/*设置内嵌的元素在 3D 空间如何呈现：保留 3D*/<br />    -webkit-transform-style: preserve-3d;    <br />/*（设置进行转换的元素的背面在面对用户时是否可见：隐藏）*/<br />    -webkit-backface-visibility: hidden;<br />}</pre><p><strong>开启硬件加速</strong></p><ul>    <li>解决页面闪白</li>    <li>    <p>保证动画流畅</p>    </li></ul><pre class="brush:js">.css {<br />   -webkit-transform: <span class="token function">translate3d(<span class="token number">0, <span class="token number">0, <span class="token number">0);<br />   -moz-transform: <span class="token function">translate3d(<span class="token number">0, <span class="token number">0, <span class="token number">0);<br />   -ms-transform: <span class="token function">translate3d(<span class="token number">0, <span class="token number">0, <span class="token number">0);<br />   transform: <span class="token function">translate3d(<span class="token number">0, <span class="token number">0, <span class="token number">0);<br />}</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></pre><p>设计高性能CSS3动画的几个要素</p><ul>    <li>尽可能地使用合成属性transform和opacity来设计CSS3动画，</li>    <li>不使用position的left和top来定位</li>    <li>利用translate3D开启GPU加速</li></ul><h4>26. android 上去掉语音输入按钮</h4><pre class="brush:js">input::-webkit-input-speech-button {display: none}</pre><h2>框架</h2><h4>1. 移动端基础框架</h4><ul>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fzeptojs%7Ccom%2F" target="_blank">zepto.js</a>&nbsp;语法与jquery几乎一样，会jquery基本会zepto~</li>    <li>    <p><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fcubiq%7Corg%2Fiscroll-5" target="_blank">iscroll.js</a>&nbsp;解决页面不支持弹性滚动，不支持fixed引起的问题~ 实现下拉刷新，滑屏，缩放等功能~</p>    </li>    <li>    <p><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Funderscorejs%7Corg%2F" target="_blank">underscore.js</a>&nbsp;该库提供了一整套函数式编程的实用功能，但是没有扩展任何JavaScript内置对象。</p>    </li>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=https%3A%2F%2Fgithub%7Ccom%2Fftlabs%2Ffastclick" target="_blank">fastclick</a>&nbsp;加快移动端点击响应时间</li>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fdaneden%7Cgithub%7Cio%2Fanimate%7Ccss%2F" target="_blank">animate.css</a>&nbsp;CSS3动画效果库</li></ul><h4>2. 滑屏框架</h4><p>适合上下滑屏、左右滑屏等滑屏切换页面的效果</p><ul>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=https%3A%2F%2Fgithub%7Ccom%2Fpeunzhang%2Fslip%7Cjs" target="_blank">slip.js</a></li>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=https%3A%2F%2Fgithub%7Ccom%2Fpeunzhang%2FiSlider" target="_blank">iSlider.js</a></li>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=https%3A%2F%2Fgithub%7Ccom%2Fpeunzhang%2Ffullpage" target="_blank">fullpage.js</a></li></ul><h4>3.瀑布流框架</h4><ul>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fmasonry%7Cdesandro%7Ccom%2F" target="_blank">masonry</a></li></ul><h3>工具推荐</h3><ul>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fcaniuse%7Ccom%2F" target="_blank">caniuse</a>&nbsp;各浏览器支持html5属性查询</li>    <li><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fpaletton%7Ccom%2F%23uid%3D1000u0kllllaFw0g0qFqFg0w0aF" target="_blank">paletton</a>&nbsp;调色搭配</li></ul><p><a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fljinkai%7Cgithub%7Cio%2F2015%2F06%2F06%2Fmobile-web-skill%2F" target="_blank">查看链接</a></p><h2>阻止缩放</h2><p>缺省的多点触摸设置不是特别的好用，因为你的滑动和手势往往与浏览器的行为有关联，比如说滚动和缩放。</p><p>要禁用缩放功能的话，使用下面的元标记设置你的视图区（viewport），这样其对于用户来说就是不可伸缩的了：</p><pre class="brush:html">content=&quot;width=device-width, initial-scale=1.0, user-scalable=no&quot;&gt;&nbsp;<p>&nbsp;</p></pre><p>看看<a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http://www.html5rocks.com/mobile/mobifying.html#toc-meta-viewport" target="_blank">这篇关于移动HTML 5</a>&nbsp;的文章，了解更多关于视图区设置的信息。</p><h2>阻止滚动</h2><p>一些移动设备有缺省的touchmove行为，比如说经典的iOS overscroll效果，当滚动超出了内容的界限时就引发视图反弹。这种做法在许多多点触控应用中会带来混乱，但要禁用它很容易。</p><pre class="brush:js">document.body.addEventListener('touchmove', function(event) {&nbsp;<br />&nbsp; &nbsp; event.preventDefault();&nbsp;<br />}, false);</pre><h2><strong>细心渲染</strong>&nbsp;</h2><p>如果你正在编写的多点触控应用涉及了复杂的多指手势的话，要小心地考虑如何响应触摸事件，因为一次要处理这么多的事情。考虑一下前面一节中的在屏幕上画出所有触点的例子，你可以在有触摸输入的时候就立刻进行绘制：</p><pre class="brush:js">canvas.addEventListener('touchmove', function(event) {&nbsp;<br />&nbsp; &nbsp; renderTouches(event.touches);&nbsp;<br />},</pre><p>不过这一技术并不是要随着屏幕上的手指个数的增多而扩充，替代做法是，可以跟踪所有的手指，然后在一个循环中做渲染，这样可获得更好的性能：</p><pre class="brush:js">var touches = []&nbsp;<br />canvas.addEventListener('touchmove', function(event) {&nbsp;<br />&nbsp; &nbsp; touches = event.touches;&nbsp;<br />}, false);&nbsp;<br /><br />// 设置一个每秒60帧的定时器&nbsp;<br />timer = setInterval(function() {&nbsp;<br />&nbsp; &nbsp; renderTouches(touches);&nbsp;<br />}, 15);</pre><p>提示&nbsp;：setInterval不太适合于动画，因为它没有考虑 到浏览器自己的渲染循环。现代的桌面浏览器提供了requestAnimationFrame这一函数，基于性能和电池工作时间原因，这是一个更好的选 择。一但浏览器提供了对该函数的支持，那将是首选的处理事情的方式。</p><h2>使用targetTouches和changedTouches</h2><p>要记住的一点是，event.touches是与屏幕接触的所有手指的一个数组，而不仅是位于目标DOM元素上的那些。你可能会发现使用 event.targetTouches和event.changedTouches来代替event.touches更有用一些。</p><p>最后一点，因为你是在为移动设备做开发，因此你应该要留心移动的最佳做法，这些在<a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http://www.html5rocks.com/mobile/mobifying.html" target="_blank">Eric Bidelman的文章</a>&nbsp;中有论及，以及要了解<a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http://www.w3.org/TR/mwabp/" target="_blank">这一W3C文档</a>&nbsp;。</p></div>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2183.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2183</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2183&amp;key=3d98b22b</trackback:ping></item><item><title>详解：CSS3 响应式布局 Media Queries 媒体查询</title><author>camnpr@163.com (佚名)</author><link>http://camnpr.com/html-css/2152.html</link><pubDate>Fri, 25 Sep 2015 10:44:50 +0800</pubDate><guid>http://camnpr.com/html-css/2152.html</guid><description><![CDATA[<h2>css3 响应式布局定义</h2><blockquote><p>响应式:就是根据不同设备,或者设备不同分辨率,动态给出对应的样式变化</p></blockquote><h2>响应不同的设备</h2><blockquote><p>涉及到 css 中的 Media Queries ,这个词组被译为 &ldquo;媒体查询&rdquo;</p></blockquote><h2>Media Queries 用法如下:</h2><pre class="brush:html">&lt;link href=&quot;css/main.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&gt;</pre><p>或者另外一种引入css 文件的方法</p><pre class="brush:html">&lt;style type=&quot;text/css&quot; media=&quot;screen&quot;&gt;<br />   @import url(&quot;css/style.css&quot;);<br /> &lt;/style&gt;</pre><blockquote><blockquote><p>上面都直接在引用的 css 文件引用中使用 media 标识</p></blockquote></blockquote><h2>media 标识是什么</h2><blockquote><p>通常来讲,media 是指设备类型 media_type 对应的有下面几种</p></blockquote><ol>    <li>    <ul>        <li>all 所有设备</li>    </ul>    </li>    <li>    <ul>        <li>aural 听觉设备</li>    </ul>    </li>    <li>    <ul>        <li>braille 点字触觉设备</li>    </ul>    </li>    <li>    <ul>        <li>handled 便携设备,如 手机,平板电脑</li>    </ul>    </li>    <li>    <ul>        <li>print 打印预览图等</li>    </ul>    </li>    <li>    <ul>        <li>projection 投影设备</li>    </ul>    </li>    <li>    <ul>        <li>screen 显示器,笔记本,移动端等设备</li>    </ul>    </li>    <li>    <ul>        <li>tty 如打字机或终端等设备</li>    </ul>    </li>    <li>    <ul>        <li>tv 电视机等设备</li>    </ul>    </li>    <li>    <ul>        <li>embossed 盲文打印机</li>    </ul>    </li></ol><p>所以,我们在上面的 style 文件中定义了 media_type=&quot;screen&quot;</p><blockquote><blockquote><p>就是指当你的设备是 显示器,笔记本,移动端的时候,加载此 css 样式文件</p></blockquote></blockquote><h2>Media Queries 的另外一种用法:</h2><blockquote><p>在样式定义时,指定 Media type 类型</p></blockquote><pre class="brush:css">@media screen and (max-width:1024px){<br />    .background {<br />        background:#fff;<br />    }<br />}</pre><blockquote><p>上面的样式定义前使用 @media 属性来指定 media_type 是 screen</p></blockquote><h2>这里注意,除了限制在 screen 设备上使用,后面还有 and 字符 连接了一个宽度限制</h2><h2>我们就来谈谈Media Queries 的响应式设计</h2><blockquote><p>上面的示例 css 定义提到了 and (max-width:1024px)</p></blockquote><hr /><h2>这是什么意思呢? 当屏幕宽度小于 1024px 时, blackground 类的样式发生变化,背景色变成 #fff ;</h2><p>是不是很神奇,没错 media 可以可以确定当前媒体环境的变化情况,根据你的媒体 宽度来动态加载不同的样式,达到响应式布局.</p><blockquote><p>那么问题来了,如果根据不同的媒体 或者 媒体的不同分比率(水平宽度) 能不能加载不同的css 文件呢?</p><blockquote><p>当然可以</p></blockquote></blockquote><p>我们可以这样引用 css 文件</p><pre class="brush:html">&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;main.css&quot; media=&quot;screen and (min-width:800px)&quot; /&gt;</pre><blockquote><p>上面的定义告诉我们,当媒体是 电脑,笔记本,移动设备屏幕时,并且水平宽度大于 800px 就加载使用 main.css 样式文件</p></blockquote><h2>另外 media 属性还支持其他关键词 ,比如 not ,only</h2><p>not: 表示当前媒体排除指定的设备 @media not print</p><blockquote><p>上面定义的样式排除打印机</p></blockquote><p>only: 用来指定特定的设备 @media only screen</p><blockquote><p>上面定义告诉我们这个样式 只支持 台式机,笔记本,移动设备屏幕</p></blockquote>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2152.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2152</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2152&amp;key=73c36577</trackback:ping></item><item><title>input type=&amp;quot;file&amp;quot;在vivo手机上，弹出选项里有一个关闭的叉，点击后，背景的蒙层还显示</title><author>camnpr@163.com (佚名)</author><link>http://camnpr.com/html-css/2151.html</link><pubDate>Wed, 23 Sep 2015 11:54:56 +0800</pubDate><guid>http://camnpr.com/html-css/2151.html</guid><description><![CDATA[<div id="noimgcss"><p>如下代码：</p><pre>&lt;form&gt;<br>&lt;input type="file" accept="image/*" /&gt;<br>&lt;/form&gt;</pre><p>在vivo手机上，弹出选项。有一个关闭的叉。 当点击这个叉后，背景的蒙层还显示，怎么解决？</p><p>如图：<img src="http://camnpr.com/upload/2015/9/201509231116568740.png" alt="vivo手机 上传图片" width="301" height="192"></p><p>看到这个，无从下手，百度搜索（一个公司如果连google也访问不了，那也是够了），也没有相关信息可用。</p><p>首先，我们解决的思路可以是，如果大公司的网站也有这个问题，那么可以告诉测试人员，这个问题，目前还没有解决方案。</p><p>于是，我用vivo手机访问了百度图片（http://image.baidu.com/search/wiseindex?tn=wiseindex）也有上传图片的，经过测试，没有这个问题。</p><p><img src="http://camnpr.com/upload/2015/9/201509231117017441.png" alt="vivo手机访问百度图片 上传图片" width="291" height="315"><br data-mce-bogus="1"></p><p>那么该如何解决呢？</p><p>分析一下百度图片的上传方式？</p></div>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2151.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2151</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2151&amp;key=6f7dd783</trackback:ping></item><item><title>如何禁止浏览器系统默认样式？-webkit-appearance ios默认Safari</title><author>kuabaobao_com@163.com (kuabaobao)</author><link>http://camnpr.com/html-css/2110.html</link><pubDate>Thu, 27 Aug 2015 10:52:10 +0800</pubDate><guid>http://camnpr.com/html-css/2110.html</guid><description><![CDATA[<p>在开发移动设备<a href="http://camnpr.com/catalog.asp?tags=HTML5" target="_blank">Html5页面</a>时,有没有遇到过,你设置的样式,在ios 设备里面面目全非了.</p><p>尤其是和安卓设备对比后,会让你有种不相信css 的感觉.</p><p>&nbsp;</p><p>其实在 ios设备中使用 Safari 浏览器时.</p><p>你页面里面的 input ,button ,submit ,reset 等元素都会被载入系统默认的css 来控制.</p><p>&nbsp;</p><p>那么问题来了,如果默认禁止浏览器载入这些默认样式呢?</p><p>&nbsp;</p><p>在你的css 样式中引入如下:</p><pre class="brush:css">input[type=&quot;submit&quot;],&nbsp;&nbsp;<br />input[type=&quot;reset&quot;],&nbsp;&nbsp;<br />input[type=&quot;button&quot;],&nbsp;&nbsp;<br />button&nbsp;{&nbsp;&nbsp;<br />-webkit-appearance:&nbsp;none;&nbsp;&nbsp;<br />}</pre><p>&nbsp;</p><p>使用上面的定义,可以改变webkit 内核浏览器的默认样式.</p>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2110.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2110</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2110&amp;key=7b2c4d0c</trackback:ping></item><item><title>移动H5前端性能优化指南</title><author>kuabaobao_com@163.com (kuabaobao)</author><link>http://camnpr.com/html-css/2109.html</link><pubDate>Sat, 22 Aug 2015 10:54:18 +0800</pubDate><guid>http://camnpr.com/html-css/2109.html</guid><description><![CDATA[<div id="noimgcss"><p><img title="index.png" src="http://camnpr.com/upload/2015/8/b4063dab316dba3bd14a693ac36f2e53.png" alt="移动H5前端性能优化指南" width="700" height="989" data-bd-imgshare-binded="1" data-mce-selected="1" /></p><h2 style="margin: 0px 0px 10px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 22px; font-weight: normal; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: rgb(17, 17, 17); white-space: normal; text-align: center; background-color: rgb(255, 255, 255);" data-mce-style="margin: 0px 0px 10px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 22px; font-weight: normal; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: #111111; white-space: normal; text-align: center; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">移动H5前端性能优化指南</span></span></h2><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">概述</span></p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;">1. PC优化手段在Mobile侧同样适用<br />2. 在Mobile侧我们提出<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(128, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #800000;">三秒种渲染完成首屏指标</span><br />3. 基于第二点，首屏加载3秒完成或使用Loading<br />4. 基于联通3G网络平均338KB/s(2.71Mb/s)，所以<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(128, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #800000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">首屏资源不应超过1014KB</span></span><br />5. Mobile侧因手机配置原因，除加载外渲染速度也是优化重点<br />6. 基于第五点，要合理处理代码减少渲染损耗<br />7. 基于第二、第五点，所有<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(128, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #800000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">影响首屏加载和渲染的代码应在处理逻辑中后置</span></span><br />8. 加载完成后用户交互使用时也需注意性能<br /><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">优化指南</span></p><h3 style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: #333333; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(51, 102, 255);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #3366ff;">[加载优化]</span></h3><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;">加载过程是最为耗时的过程，可能会占到总耗时的80%时间，因此是优化的重点</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 减少HTTP请求</span></strong><br />因为手机浏览器同时响应请求为4个请求（Android支持4个，iOS 5后可支持6个），所以要尽量减少页面的请求数，<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">首次加载同时请求数不能超过4个</span><br />a) 合并CSS、JavaScript<br />b) 合并小图片，使用雪碧图</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 缓存</span></strong><br />使用缓存可以减少向服务器的请求数，节省加载时间，<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">所以所有静态资源都要在服务器端设置缓存，并且尽量使用长Cache（长Cache资源的更新可使用时间戳）</span><br />a) 缓存一切可缓存的资源<br />b) 使用长Cache（使用时间戳更新Cache）<br />c) 使用外联式引用CSS、JavaScript</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 压缩HTML、CSS、JavaScript</span></strong><br />减少资源大小可以加快网页显示速度，所以要<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">对HTML、CSS、JavaScript等进行代码压缩，并在服务器端设置GZip</span><br />a) 压缩（例如，多余的空格、换行符和缩进）<br />b) 启用GZip</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 无阻塞</span></strong><br />写在HTML头部的JavaScript（无异步），和写在HTML标签中的Style会阻塞页面的渲染，因此<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">CSS放在页面头部并使用Link方式引入，避免在HTML标签中写Style，JavaScript放在页面尾</span></p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;">部或使用异步方式加载</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot;&nbsp;</span>使用首屏加载</strong><br />首屏的快速显示，可以大大提升用户对页面速度的感知，因此应<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">尽量针对首屏的快速显示做优化</span></p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 按需加载</span></strong><br /><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">将不影响首屏的资源和当前屏幕资源不用的资源放到用户需要时才加载</span>，可以大大提升重要资源的显示速度和降低总体流量<br />PS：<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">按需加载会导致大量重绘，影响渲染性能</span><br />a) LazyLoad<br />b) 滚屏加载<br />c) 通过Media Query加载</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 预加载</span></strong><br />大型重资源页面（如游戏）可<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">使用增加Loading的方法，资源加载完成后再显示页面。但Loading时间过长，会造成用户流失</span><br />对用户行为分析，<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">可以在当前页加载下一页资源</span>，提升速度<br />a) 可感知Loading(如进入空间游戏的Loading)<br />b) 不可感知的Loading（如提前加载下一页）</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 压缩图片</span></strong><br /><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">图片是最占流量的资源，因此尽量避免使用他，使用时选择最合适的格式（实现需求的前提下，以大小判断），合适的大小，然后使用智图压缩，同时在代码中用Srcset来按需显示</span><br /><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">PS：过度压缩图片大小影响图片显示效果</span><br /><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">a) 使用智图（&nbsp;<a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://zhitu.tencent.com/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">http://zhitu.tencent.com/</a>&nbsp;）</span><br />b) 使用其它方式代替图片(1. 使用CSS3&nbsp;2. 使用SVG&nbsp;3. 使用IconFont)<br />c) 使用Srcset<br />d) 选择合适的图片(1. webP优于JPG&nbsp;2. PNG8优于GIF)<br />e) 选择合适的大小（1. 首次加载不大于1014KB&nbsp;2. 不宽于640（基于手机屏幕一般宽度））</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 减少Cookie</span></strong><br />Cookie会影响加载速度，所以静态资源域名不使用Cookie</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 避免重定向</span></strong><br />重定向会影响加载速度，所以在服务器正确设置避免重定向</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 异步加载第三方资源</span></strong><br />第三方资源不可控会影响页面的加载和显示，因此要异步加载第三方资源</p><h3 style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: #333333; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(51, 102, 255);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #3366ff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">[脚本执行优化]</span></span></h3><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">脚本处理不当会阻塞页面加载、渲染</span>，因此在使用时需当注意</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; CSS写在头部，JavaScript写在尾部或异步</span></strong></p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 避免图片和iFrame等的空Src</span></strong><br />空Src会重新加载当前页面，影响速度和效率</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 尽量避免重设图片大小</span></span><br />重设图片大小是指在页面、CSS、JavaScript等中多次重置图片大小，多次重设图片大小会引发图片的多次重绘，影响性能</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot;&nbsp;图片尽量避免使用DataURL</strong></span><br />DataURL图片没有使用图片的压缩算法文件会变大，并且要解码后再渲染，加载慢耗时长</p><h3 style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: #333333; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(51, 102, 255);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #3366ff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">[CSS优化]</span></span></h3><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 尽量避免写在HTML标签中写Style属性</span></span></p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><strong style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot; 避免CSS表达式</span></strong><br />CSS表达式的执行需跳出CSS树的渲染，因此请避免CSS表达式</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 移除空的CSS规则</span></span><br />空的CSS规则增加了CSS文件的大小，且影响CSS树的执行，所以需移除空的CSS规则</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 正确使用Display的属性</span></span><br />Display属性会影响页面的渲染，因此请合理使用<br />a) display:inline后不应该再使用width、height、margin、padding以及float<br />b) display:inline-block后不应该再使用float<br />c) display:block后不应该再使用vertical-align<br />d) display:table-*后不应该再使用margin或者float</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 不滥用Float</span></span><br />Float在渲染时计算量比较大，尽量减少使用</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 不滥用Web字体</span></span><br />Web字体需要下载，解析，重绘当前页面，尽量减少使用</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 不声明过多的Font-size</span></span><br />过多的Font-size引发CSS树的效率</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 值为0时不需要任何单位</span></span><br />为了浏览器的兼容性和性能，值为0时不要带单位</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 标准化各种浏览器前缀</span></span><br />a) 无前缀应放在最后<br />b) CSS动画只用 （-webkit- 无前缀）两种即可<br />c) 其它前缀为 -webkit- -moz- -ms- 无前缀 四种，（-o-Opera浏览器改用blink内核，所以淘汰）</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 避免让选择符看起来像正则表达式</span></span><br />高级选择器执行耗时长且不易读懂，避免使用</p><h3 style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: #333333; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(51, 102, 255);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #3366ff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">[JavaScript执行优化]</span></span></h3><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 减少重绘和回流</span></span><br />a) 避免不必要的Dom操作<br />b) 尽量改变Class而不是Style，使用classList代替className<br />c) 避免使用document.write<br />d) 减少drawImage</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot;&nbsp;缓存Dom选择与计算</span></span><br />每次Dom选择都要计算，缓存他</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 缓存列表.length</span></span><br />每次.length都要计算，用一个变量保存这个值</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 尽量使用事件代理，避免批量绑定事件</span></span></p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 尽量使用ID选择器</span></span><br />ID选择器是最快的</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; TOUCH事件优化</span></span><br />使用touchstart、touchend代替click，因快影响速度快。但应注意Touch响应过快，易引发误操作</p><h3 style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: rgb(51, 51, 51); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin: 0px 0px 8px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 18px; font-stretch: inherit; line-height: 2; vertical-align: baseline; color: #333333; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(51, 102, 255);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #3366ff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">[渲染优化]</span></span></h3><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;">&middot;&nbsp;<span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">HTML使用Viewport</span></span><br />Viewport可以加速页面的渲染，请使用以下代码<br /><em style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&lt;meta name=&rdquo;viewport&rdquo; content=&rdquo;width=device-width, initial-scale=1&Prime;&gt;</em></p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 减少Dom节点</span></span><br />Dom节点太多影响页面的渲染，应尽量减少Dom节点</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 动画优化</span></span><br />a) 尽量使用CSS3动画<br />b) 合理使用requestAnimationFrame动画代替setTimeout<br />c) 适当使用Canvas动画&nbsp;5个元素以内使用css动画，5个以上使用Canvas动画（iOS8可使用webGL）</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; 高频事件优化</span></span><br />Touchmove、Scroll 事件可导致多次渲染<br />a) 使用requestAnimationFrame监听帧变化，使得在正确的时间进行渲染<br />b) 增加响应变化的时间间隔，减少重绘次数</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 0, 0);" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #000000;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">&middot; GPU加速</span></span><br />CSS中以下属性（CSS3 transitions、CSS3 3D transforms、Opacity、Canvas、WebGL、Video）来触发GPU渲染，请合理使用<br />PS：过渡使用会引发手机过耗电增加</p><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 28.5px; vertical-align: baseline; word-wrap: break-word; word-break: normal; color: #111111; white-space: normal; background-color: #ffffff;"><span style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: bolder; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">参考资料</span></p><ul class=" list-paddingleft-2" style="margin-top: 0.4em; margin-bottom: 1em; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 22.5px; vertical-align: baseline; color: rgb(17, 17, 17); white-space: normal; background-color: rgb(255, 255, 255);" data-mce-style="margin-top: 0.4em; margin-bottom: 1em; padding: 0px; border: 0px; font-family: Source-Han-Normal188073; font-size: 15px; font-stretch: inherit; line-height: 22.5px; vertical-align: baseline; color: #111111; white-space: normal; background-color: #ffffff;">    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://tgideas.qq.com/webplat/info/news_version3/804/808/811/m579/201412/293834.shtml" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">移动页面性能优化</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="https://github.com/cssmagic/blog/issues/20" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">[译]&nbsp;如何做到一秒渲染一个移动页面</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://lists.w3.org/Archives/Public/public-html-ig-zh/2014May/0005.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">首屏渲染优化提案反馈（原：Re:&nbsp;答复:&nbsp;中文兴趣小组5月5日电话会议）</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://isux.tencent.com/html5-game-development-cheats.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">HTML5游戏前端开发秘籍</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://isux.tencent.com/emancipate-gpu.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">被解放的GPU</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://s5s5.github.io/CSS-Animations/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">CSS动画</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://www.html5rocks.com/en/tutorials/speed/high-performance-animations/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">High Performance Animations</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="https://developers.google.com/speed/docs/insights/rules" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">PageSpeed Insights规则</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="https://developer.yahoo.com/performance/rules.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">Best Practices for Speeding Up Your Web Site</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://browserdiet.com/en/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">How to lose weight (in the browser)</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://nomospace.github.io/posts/css-lint.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">关注&nbsp;CSS Lint</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://blog.91gaoqing.com/archives/146.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">HTML5应用开发功耗调优化小结</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://blog.csdn.net/milado_nju/article/details/39271463" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">理解WebKit和Chromium: Chromium WebView和Chrome浏览器渲染机制</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="https://developers.google.com/web/fundamentals/performance/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">Optimizing Performance &mdash; Web Fundamentals</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://www.w3cfuns.com/article-5601016-1-1.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">移动前端工作的那些事&mdash;前端制作之动画效率问题简析</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://www.sitepoint.com/optimizing-critical-rendering-path/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">Optimizing the Critical Rendering Path</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://fex.baidu.com/blog/2014/05/build-performance-monitor-in-7-days/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">7&nbsp;天打造前端性能监控系统</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://tgideas.qq.com/webplat/info/news_version3/804/808/811/m579/201411/291773.shtml" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">数据驱动设计</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://tgideas.qq.com/webplat/info/news_version3/804/808/811/m579/201404/258325.shtml" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">为你的移动页面寻找一丝新意（技术篇）&mdash;&mdash;手机互动网页项目总结（下）</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://www.imageoptimization.info/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">Image Optimization</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://www.cnblogs.com/yexiaochai/p/3759959.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">[webapp的优化整理]要做移动前端优化的朋友进来看看吧</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://www.egret-labs.org/blog/3097.html" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">Egret Framework Canvas Renderer性能优化</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://www.stevesouders.com/blog/2008/03/20/roundup-on-parallel-connections/" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">Roundup on Parallel Connections</a></p>    </li>    <li>    <p><a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" href="http://www.speedtest.cn/info/2014-8th" target="_blank" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">2014年第二季度全国网速实测报告</a></p>    </li></ul><p style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: 24.7000007629395px; vertical-align: baseline; word-wrap: break-word; word-break: normal;" data-mce-style="margin-top: 0px; margin-bottom: 28px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: 24.7000007629395px; vertical-align: baseline; word-wrap: break-word; word-break: normal;"><span class="entry_link" style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline;">出处：腾讯ISUX (<a style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: rgb(0, 144, 255); text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;" title="移动H5前端性能优化指南" href="http://isux.tencent.com/h5-performance.html" data-mce-style="margin: 0px; padding: 0px; border: 0px; font-family: inherit; font-size: inherit; font-style: inherit; font-variant: inherit; font-weight: inherit; font-stretch: inherit; line-height: inherit; vertical-align: baseline; color: #0090ff; text-decoration: none; transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear; -webkit-transition: color 0.2s linear, background-color 0.2s linear, border-color 0.2s linear;">http://isux.tencent.com/h5-performance.html</a>)</span></p></div>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2109.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2109</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2109&amp;key=5809eef9</trackback:ping></item><item><title>详解css3 pointer-events（阻止hover、active、onclick等触发事件来防止按钮重复点击）</title><author>camnpr@163.com (佚名)</author><link>http://camnpr.com/html-css/2090.html</link><pubDate>Thu, 06 Aug 2015 10:31:47 +0800</pubDate><guid>http://camnpr.com/html-css/2090.html</guid><description><![CDATA[<p><code>pointer-events</code>更像是JavaScript，它能够：</p><ul>    <li>阻止用户的点击动作产生任何效果</li>    <li>阻止缺省鼠标指针的显示</li>    <li>阻止CSS里的<code>hover</code>和<code>active</code>状态的变化触发事件</li>    <li>阻止JavaScript点击动作触发的事件</li></ul><p><strong>实际代码使用中案例：</strong></p><p>1、提交页面，提交按钮点击后，添加这个样式属性（style=&quot;pointer-events&quot;），来<span style="color: rgb(255, 0, 0);">防止重复提交</span>。 @camnpr</p><p>2、一些层的绝对定位，覆盖按钮，穿透可以点击它。等等。</p><p><strong>来看下具体用法：</strong></p><pre class="css">pointer-events:  auto | none | visiblePainted | visibleFill | visibleStroke | visible | painted | fill | stroke | all | inherit</pre><p>pointer-events属性有很多值，但是对于浏览器来说，只有auto和non两个值可用，其它的几个是针对SVG的(本身这个属性就来自于SVG技术)。</p><p>@郑州网建</p><h3>pointer-events属性值详解</h3><ul>    <li>auto&mdash;&mdash;效果和没有定义pointer-events属性相同，鼠标不会穿透当前层。在SVG中，该值和visiblePainted的效果相同。</li>    <li>none&mdash;&mdash;元素不再是鼠标事件的目标，鼠标不再监听当前层而去监听下面的层中的元素。但是如果它的子元素设置了pointer-events为其它值，比如auto，鼠标还是会监听这个子元素的。</li>    <li>其它属性值为SVG专用，这里不再多介绍了。</li></ul><h3>浏览器兼容性</h3><p>Firefox 3.6+和chrome 2.0+ 以及safari 4.0+都支持这个CSS3属性，IE6/7/8/9都不支持（IE11又支持，不过很好的一点是在ie中给a加disabled 点击事件自动无效。），Opera在SVG中支持。<strong>但是</strong>该属性HTML中<strong>不支持</strong>。</p><p>&nbsp;</p>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2090.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2090</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2090&amp;key=b03ba8ca</trackback:ping></item><item><title>用meta name=&amp;quot;renderer&amp;quot; content=&amp;quot;webkit|ie-comp|ie-stand&amp;quot;来切换360双核安全浏览器的极速模式和兼容模式</title><author>camnpr@163.com (佚名)</author><link>http://camnpr.com/html-css/2087.html</link><pubDate>Fri, 31 Jul 2015 10:29:53 +0800</pubDate><guid>http://camnpr.com/html-css/2087.html</guid><description><![CDATA[<div id="noimgcss"><p><img src="http://camnpr.com/upload/2015/7/201507301351344282.png" alt="360浏览器" width="256" height="256" /></p><p>我开发了一个网站，大量采用了html5和css3，希望用户都以webkit内核打开页面，但是测试却发现360的以ie内核打开为推荐模式，不知原因为何。其实360给网站开发者设计了一种选择的方法，只要加入一段Meta标签代码就可以解决。</p><p>以下信息摘自<a href="http://camnpr.com/TuiJianTools/Handler/gotoUrl.ashx?url=http%3A%2F%2Fse%7C360%7Ccn%2Fv6%2Fhelp%2Fmeta%7Chtml" target="_blank">360官方网站</a>：</p><h2>浏览模式</h2><p>极速模式、兼容模式及IE9高速模式是360浏览器显示网页时使用的三种模式：</p><p><img src="http://camnpr.com/TuiJianTools/images/icon/极速模式.png" alt="极速模式" width="29" height="26" />表示极速模式</p><p><img src="http://camnpr.com/TuiJianTools/images/icon/兼容模式.png" alt="兼容模式" width="29" height="26" />表示兼容模式</p><p><img src="http://camnpr.com/TuiJianTools/images/icon/IE9IE10模式.png" alt="IE9IE10模式" width="29" height="26" />表示IE9/IE10模式（仅在安装了IE9或IE10后可用）</p><p>360极速浏览器会自动为您选择使用适合每个网站的浏览模式。所以，通常您不用了解几种内核的区别。</p><h2>几种模式各有什么特点</h2><p>极速模式下，网站打开速度快，但某些网站在极速模式下可能出现兼容性问题，显示不正常。<br />兼容模式下，网站打开速度比极速模式略低，但网页兼容性问题较少。<br />IE9/IE10模式下，网站会使用IE9/IE10的渲染方式渲染，支持硬件加速及IE9/IE10全新的脚本渲染引擎。</p><p>切换浏览模式时，360极速浏览器将会自动同步双核间的数据，让您在双核间能无缝切换。</p><h2>用户体验计划</h2><p>在您加入用户体验计划的情况下，我们会将切换的网址发送到360网站，以便我们完善兼容列表库，改进产品。</p><p>上传的数据不包含具有您个体特征的信息，且不会泄漏给第三方个人或机构。</p><p>若不希望上传切换的网址，您只需在&ldquo;高级选项&rdquo;里去掉勾选<br />&ldquo; 将使用情况统计信息和崩溃报告自动发送给360极速浏览器网站，帮助我们完善360极速浏览器&rdquo;即可。</p><h2>背景介绍</h2><p>由于众所周知的情况，国内的主流浏览器都是双核浏览器：基于Webkit内核用于常用网站的高速浏览。基于IE的内核用于兼容网银、旧版网站。以360的几款浏览器为例，我们优先通过Webkit内核渲染主流的网站，只有小量的网站通过IE内核渲染，以保证页面兼容。在过去很长一段时间里，我们主要的控制手段是一个几百k大小网址库，一个通过长期人工运营收集的网址库。</p><p>尽管我们努力通过用户反馈、代码标签智能判断技术提高浏览器的自动切核准确率。但是在很多情况下，我们仍然无法达到百份百正确。因此，我们新增加了一个控制手段：内核控制Meta标签。只要你在自己的网站里增加一个Meta标签，告诉360浏览器这个网址应该用哪个内核渲染，哪么360浏览器就会在读取到这个标签后，立即切换对应的内核。并将这个行为应用于这个二级域名下所有网址。<br />目前该功能已经在所有的360安全浏览器实现。我们也建议其它浏览器厂商一起支持这个实现。让这个控制标签成为行业标准。</p><h2>代码示例</h2><p>在head标签中添加一行代码：</p><pre class="brush:html">&lt;html&gt;<br />&lt;head&gt;<br />&lt;meta name=&quot;renderer&quot; content=&quot;webkit|ie-comp|ie-stand&quot;&gt;<br />&lt;/head&gt;<br />&lt;body&gt;<br />&lt;/body&gt;<br />&lt;/html&gt;</pre><p>content的取值为webkit,ie-comp,ie-stand之一，区分大小写，分别代表用webkit内核，IE兼容内核，IE标准内核。<br />若页面需默认用极速核，增加标签：<code>&lt;meta name=&quot;renderer&quot; content=&quot;webkit&quot;&gt;</code><br />若页面需默认用ie兼容内核，增加标签：<code>&lt;meta name=&quot;renderer&quot; content=&quot;ie-comp&quot;&gt;</code><br />若页面需默认用ie标准内核，增加标签：<code>&lt;meta name=&quot;renderer&quot; content=&quot;ie-stand&quot;&gt;</code></p><blockquote><p>注意：引号要英文状态下的，直接复制代码后看一下格式对不对，请自行更正。<del><br /></del></p></blockquote><h2>各渲染内核的技术细节</h2><table class="info_table mce-item-table">    <tbody>        <tr>            <th>内核</th>            <td>Webkit</td>            <td>IE兼容</td>            <td>IE标准</td>        </tr>        <tr>            <th>文档模式</th>            <td>Chrome 21</td>            <td>IE6/7</td>            <td>IE9/IE10/IE11(取决于用户的IE)</td>        </tr>        <tr>            <th>HTML5支持</th>            <td>YES</td>            <td>NO</td>            <td>YES</td>        </tr>        <tr>            <th>ActiveX控件支持</th>            <td>NO</td>            <td>YES</td>            <td>YES</td>        </tr>    </tbody></table><h2>各内核UA示例</h2><p><img src="http://camnpr.com/upload/2015/7/201507301351350871.png" alt="" data-bd-imgshare-binded="1" /></p><h2>备注</h2><p>这个功能其实和IE9的X-UA-Compatible很类似，关于IE几个内核的实现介绍，请看：</p><p><a href="http://camnpr.com/html-css/specify-IE-document-compatibility-mode.html" target="_blank">指定IE的文档兼容模式 meta X-UA-<strong>Compatible</strong>&nbsp;EmulateIE7</a></p><p><a href="http://camnpr.com/html-css/524.html" target="_blank">meta http-equiv=&quot;X-UA-<strong>Compatible</strong>&quot; content=&quot;IE=7&quot;</a></p><p><a href="http://camnpr.com/html-css/77.html" target="_blank">IE=EmulateIE7 标签的作用</a></p><p><br /><a title="" href="http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx" target="_blank" data-original-title="">http://blogs.msdn.com/b/ie/archive/2010/06/16/ie-s-compatibility-features-for-site-developers.aspx</a></p><blockquote><p>了解极速模式和兼容模式使用的技术：</p><p>极速模式使用的是Webkit内核，Webkit内核是全球最快速的浏览器内核，同时支持了诸多的网页新标准，<br />但由于Webkit内核较新，国内一些网站尚未较好地支持此内核。</p><p>兼容模式使用的是IE浏览器所使用的 Trident 内核，是国内网页制作时主要兼容的浏览器内核，兼容性问题较少。</p><p>IE9/IE10模式使用的是IE9/IE10浏览器所使用的新内核，加入了硬件加速、全新的脚本渲染引擎，更标准的HMTL5及CSS3支持。</p></blockquote></div>]]></description><category>Html_Css</category><comments>http://camnpr.com/html-css/2087.html#comment</comments><wfw:comment>http://camnpr.com/</wfw:comment><wfw:commentRss>http://camnpr.com/feed.asp?cmt=2087</wfw:commentRss><trackback:ping>http://camnpr.com/cmd.asp?act=tb&amp;id=2087&amp;key=6d93b633</trackback:ping></item></channel></rss>
