Skip to content

Instantly share code, notes, and snippets.

View hjzheng's full-sized avatar
💭
I may be slow to respond.

HaoJu Zheng hjzheng

💭
I may be slow to respond.
View GitHub Profile
@hjzheng
hjzheng / table.txt
Created June 19, 2014 15:14
HTML中Table特性
th,td{padding:0;}
table{border-collapse:collapse;}
/* table css reset */
th,td{border:1px solid black; height:50px; width:100px;}
table{width:500px;}
注意事项:
1、不要给table,th,td以外的表格标签加样式;
2、单元格默认平分table 的宽度
@hjzheng
hjzheng / copy.js
Created June 19, 2014 16:17
JS浅copy和深copy
//深拷贝
function deepCopy(obj){
if(typeof obj != 'object') {
return obj;
}
var newObj = {};
for(var attr in obj) {
newObj[attr] = deepCopy(obj[attr]);
@hjzheng
hjzheng / html
Created June 23, 2014 01:35
HTML编码规范
1、所有书写均在英文半角状态下的小写;
2、id,class必须以字母开头;
3、所有标签必须闭合;
4、html标签用tab键缩进;
5、属性值必须带引号;
6、<!-- html注释 -->
7、/* css注释 */
8、ul,li/ol,li/dl,dt,dd拥有父子级关系的标签;
9、p,dt,h标签 里面不能嵌套块属性标签;
10、a标签不能嵌套a;
@hjzheng
hjzheng / regular
Last active May 30, 2018 08:58
常用的正则表达式
匹配中文:[\u4e00-\u9fa5]
行首行尾空格:^\s*|\s*$
Email:^\w+@[a-z0-9]+(\.[a-z]+){1,3}$
网址:[a-zA-z]+://[^\s]*
QQ号:[1-9][0-9]{4,9}
邮政编码:[1-9]\d{5}
身份证:[1-9]\d{14}|[1-9]\d{17}|[1-9]\d{16}x
匹配中文标点:[,。?:;‘’!“”—……、【】《》()]
@hjzheng
hjzheng / new-function
Created July 2, 2014 04:25
使用new 操作符function里面到底发生了什么?
当我们在使用new操作符,函数(构造函数)中到底放生了什么?
1.创建一个空对象
2.让空对象的__proto__(这个不同浏览器不同)成员指向了构造函数对象prototype成员对象
3.将构造函数对象的this指针替换成空对象,然后再调用Base函数
4.返回this对象
例如
function Foo(name){
this.name = name;
}
@hjzheng
hjzheng / prototype
Created July 3, 2014 11:47
类比普通属性(方法)和原型属性(方法)
function Foo(){
this.bar = "bar";//普通属性
}
Foo.prototype.bar = "prototype bar"; //原型属性
var f = new Foo();
f.bar //"bar"
使用类比记忆
@hjzheng
hjzheng / js_copy_extend.js
Last active August 29, 2015 14:03
JavaScript继承(copy继承)
//JavaScript继承
//copy继承(call and prototype)
function extend(obj1, obj2){
for(var attr in obj2){
obj1[attr] = obj2[attr];
}
}
function Person(name){
this.name = name;
@hjzheng
hjzheng / js_class_extend.js
Created July 5, 2014 13:46
JavaScript继承(类式继承)
//JavaScript 类式继承
//YUI2.9 YHAOO.lang.extend
function extend(Sub, Super) {
var F = function(){};
F.prototype = Super.prototype;
Sub.prototype = new F();
Sub.prototype.constructor = Sub;
}
function Person(name){
@hjzheng
hjzheng / js_prototype_extend.js
Created July 5, 2014 13:50
JavaScript继承(原型继承)
//JavaScript 原型继承
function extend(obj){
var F = function(){};
F.prototype = obj;
return new F();
}
var obj = {
name: "xxxx"
};
@hjzheng
hjzheng / normalize-V3.0.1.css
Last active January 4, 2017 10:34
normalize.css v3.0.1解读
/*! normalize.css v3.0.1 | MIT License | git.io/normalize */
/**
* 1. Set default font family to sans-serif.
* 2. Prevent iOS text size adjust after orientation change, without disabling
* user zoom.
* 1. 设置默认的字体sans-serif.
* 2. 当屏幕方向改变的时候, 阻止ios自动调整文本大小.
* https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust
*/