优点:
- 便于复用
- 便于管理
缺点:
- 额外的http请求
- 造成css浪费 (比如a)
- 可能造成链接404
| function getByteLen(val) { | |
| var len = 0; | |
| for (var i = 0; i < val.length; i++) { | |
| var a = val.charAt(i); | |
| if (a.match(/[^\x00-\xff]/ig) != null) { | |
| len += 2; | |
| } else { | |
| len += 1; | |
| } | |
| } |
| <!DOCTYPE html> | |
| <html lang="zh-CN"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Grids</title> | |
| <style> | |
| html, | |
| body { | |
| margin: 0; | |
| padding: 0; |
| // firefox 和 chrome 是 [1024, 6, 5, 3, 2, 1] | |
| // safari 中顺序没变 | |
| [1,3,2,5,6,1024].sort(function(a, b) { | |
| return b > a; | |
| }); | |
| // 在各中浏览器工作一致的方法 | |
| // 用正负和零来排序,而不是 true/false | |
| [1,3,2,5,6,1024].sort(function(a, b) { |
| <!DOCTYPE html> | |
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>动态加载js</title> | |
| </head> | |
| <body> | |
| <script> | |
| (function(){ | |
| function loadScript(url, callback) { |
| !function (){ | |
| 'use strict'; | |
| if (localStorage) { | |
| var docEle, | |
| w = window, | |
| d = document, | |
| l = localStorage, | |
| t = location.href, | |
| browserName=navigator.userAgent.toLowerCase(); | |
| <!doctype html> | |
| <html lang="zh-CN"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>ANGULARJS TEST</title> | |
| <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js"></script> | |
| <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular-resource.min.js"></script> | |
| </head> | |
| <body> | |
| <div ng-app="myApp" ng-controller="Ctrl1"> |
| <style> | |
| //zhihu.com | |
| .fofa-1 { | |
| font-family: 'Open Sans','Helvetica Neue',Arial,"Hiragino Sans GB",sans-serif; | |
| } | |
| //blog | |
| .fofa-2 { | |
| font-family: palatino, "times new roman", serif; | |
| } | |
| //jianshu.io |
curl -X OPTIONS -i 'http://api.example.com' -H "Origin: http://example.com"
/*iPad及以下,所有小于(不等于)960宽度的平板电脑*/
@media only screen and (max-width: 959px) {}
/*仅iPad竖屏,所有小于(不等于)960宽度的平板电脑的竖屏*/
@media only screen and (min-width: 768px) and (max-width: 959px) {}
/*iPhone及以下*/
@media only screen and (max-width: 767px) {}