Skip to content

Instantly share code, notes, and snippets.

View alex1504's full-sized avatar
🏀
On the way.

Zerui Hu alex1504

🏀
On the way.
  • South China Agricultural University
  • ShenZhen,GuangDong,China
View GitHub Profile
@alex1504
alex1504 / DetectBrowser.js
Created June 7, 2017 04:02
判断浏览器类型
function isSafari() {
return navigator.userAgent.indexOf('Safari') > 0 &&
navigator.userAgent.indexOf('Chrome') < 0;
}
function isIe() {
return navigator.userAgent.indexOf('MSIE') > 0;
;
}
@alex1504
alex1504 / normalize.css
Last active May 31, 2017 02:55
样式初始化
/* ============================== START normalize.css ==============================*/
/*! normalize.css v7.0.0 | MIT License | github.com/necolas/normalize.css */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in
* IE on Windows Phone and in iOS.
*/
html {
@alex1504
alex1504 / node-proxy-request.js
Created May 26, 2017 09:47
Node代理访问接口解决跨域问题
var express = require('express');
var app = express();
var http = require('http');
var httpServer = http.Server(app);
app.all('*', function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "X-Requested-With");
res.header("Access-Control-Allow-Methods","PUT,POST,GET,DELETE,OPTIONS");
res.header("X-Powered-By",' 3.2.1');
@alex1504
alex1504 / detect-font.js
Last active May 26, 2017 09:34
判断浏览器是否存在某种字体
(function() {
/**
* 根据测试字体与基准字体拼接后字体的宽高 和 原来基准字体的宽高进行对比,若不同,则说明测试字体存在
*/
var Detector = function() {
// 传入的字体会和下面三种字体作比较
var baseFonts = ['monospace', 'sans-serif', 'serif'];
// 使用m和w作为测试字符因为它们占据最大宽度
var testString = "mmmmmmmmmmlli";
@alex1504
alex1504 / rem-auto-resize.md
Last active May 26, 2017 09:02
rem自适应手机屏幕方案

自适应脚本方案(比例:1rem=100px)

(function(doc, win) {
    var docEl = doc.documentElement,
        resizeEvt = 'orientationchange' in window ? 'orientationchange' : 'resize',
        recalc = function() {
            var clientWidth = docEl.clientWidth;
            if (!clientWidth) return;
            if (clientWidth >= 640) {
                docEl.style.fontSize = '100px';
@alex1504
alex1504 / css-chinese-font.md
Last active April 15, 2024 03:41
css中常用font-family

实例

  • 例1(小米米官网):font: 14px/1.5 "Helvetica Neue",Helvetica,Arial,"Microsoft Yahei","Hiragino Sans GB","Heiti SC","WenQuanYi Micro Hei",sans-serif;
  • 例2(淘宝技术研发中心):font: 12px/1.5 tahoma,arial,'Hiragino Sans GB','\5b8b\4f53',sans-serif;
  • 例3(加网 ):font: 14px/1.5 'Microsoft YaHei',arial,tahoma,\5b8b\4f53,sans-serif;
  • 例4(淘宝UED):font: 12px/1 Tahoma,Helvetica,Arial,"\5b8b\4f53",sans-serif;
  • 例5(一淘UX):font-family: Helvetica, 'Hiragino Sans GB', 'Microsoft Yahei', '微软雅黑', Arial, sans-serif;
  • 例6(简书):font-family: "lucida grande", "lucida sans unicode", lucida, helvetica, "Hiragino Sans GB", "Microsoft YaHei", "WenQuanYi Micro Hei", sans-serif;

HTML,CSS,font-family:中文字体的英文名称

通用

@alex1504
alex1504 / meta.html
Last active May 26, 2017 07:16
Useful meta in mobile browser
<html>
<head>
<!-- 声明文档使用的字符编码 -->
<meta charset='utf-8'>
<!-- 优先使用 IE 最新版本和 Chrome -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
<!-- 页面描述 -->
<meta name="description" content="不超过150个字符"/>
<!-- 页面关键词 -->
<meta name="keywords" content=""/>
@alex1504
alex1504 / vanilla-vs-jquery.md
Last active May 26, 2017 07:17 — forked from liamcurry/gist:2597326
原生JS与jQuery实现方式对比

Moving from jQuery

Events

// jQuery
$(document).ready(function() {
  // code
})