Skip to content

Instantly share code, notes, and snippets.

View binnng's full-sized avatar
🎯
Focusing

binnng binnng

🎯
Focusing
View GitHub Profile
@binnng
binnng / gist:6027534
Created July 18, 2013 07:53
伪数组一系列问题
this.context = [].concat.apply([], selector);
//selector是个伪数组(元素列表),这样转换成数组不可靠,三星大部分机器会报错。
@binnng
binnng / gist:5856515
Last active March 29, 2017 06:08
CSS实现文字的多行截断
.text{
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
display: -webkit-box;
}
@binnng
binnng / gist:5733761
Created June 8, 2013 02:41
new Function的问题,函数体内的变量从全局环境找,new Function声明的函数所处作用域为全局。这点和eval不同。
var a = 1;
(function () {
var a = 3;
(new Function('console.log(a)'))(); // 1
})();
@binnng
binnng / gist:5696509
Created June 3, 2013 07:02
图片居中显示
<ul class='thumbnails'>
<li>
<a class='thumbnail'>
<img src='http://ww1.sinaimg.cn/mw690/a1d3feabjw1e57a6ito1gj205a02sq37.jpg' />
</a>
</li>
</ul>
@binnng
binnng / gist:5465093
Last active December 16, 2015 16:40
正则替换字符串问题
var b = '{comment}'.replace((new RegExp('({comment})','g')), '$123');
console.log(b); //{comment}23
var b = '{comment}'.replace((new RegExp('{comment}','g')), '$123');
console.log(b); //$123
@binnng
binnng / gist:5458764
Created April 25, 2013 10:05
firefox 18.0.1 不支持window.id方式获取dom元素
<!doctype html>
<html>
<body>
<div id="nav"></div>
</body>
<script type="text/javascript">
alert(window.nav);
/**
* 经测试
@binnng
binnng / gist:5458741
Created April 25, 2013 10:00
专门针对火狐的css hack
@-moz-document url-prefix(){
#feed_live .name{
position: relative;
top: 6px;
}
}
@binnng
binnng / gist:5449490
Created April 24, 2013 03:53
属性是可以通过delete操作符删除的,而变量是不能的。
var c = 1;
delete c; //false
d = 1;
delete d; //true
window.e = 1;
delete e; //true
@binnng
binnng / gist:5425922
Created April 20, 2013 13:10
#雅安加油!#表示哀悼,给网站置灰吧。
html {
filter: progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);
-webkit-filter: grayscale(100%);
}
@binnng
binnng / gist:5419053
Created April 19, 2013 08:54
消除iOS下type=submit的默认样式
-webkit-appearance: none;