WEB前端相关TIPS整理
06 / 06 / 2015 buling

1、单行超出省略号方法
限定高宽, 设置css:overflow: hidden; text-overflow:ellipsis; white-space:nowrap;
2、多行超出省略号方法
css:overflow: hidden; display: -webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical;
3、rgba的向下兼容方法
css:background:#ccc; background:rgba(0, 0, 0, 0.8);
=========================JS============================
1、获取窗口大小

function getWindowHeightAndWidth(){
    var obj = window,
        sname = 'inner';
    if(!('innerWidth' in window)){
        sname = 'client';
        obj = document.documentElement || document.body;
    }
    return {
        width : obj[sname+'Width'],
        height : obj[sname+'Height']
    };
}

2、array-like object 在jquery中的使用方法。如果需要让一个object在console.log时看起来像一个数组

//The object has to have length and splice
var x = {length:2, '0':'foo', '1':'bar', splice:function(){}};
jQuery.fn.init.prototype.splice = [].splice;

3、摇一摇时禁止Iphone在页面提示“撤销键入”

$(window).off('devicemotion').on('devicemotion',function(eventData){
    //dosomething(eventData.accelerationIncludingGravity);
    eventData.preventDefault(); //就是这句了
});

4、禁止页面被拖动
//去掉IOS滚动到顶部回弹一下的效果


//这里是列表可以滚动
$('#J_userchat-list').on('touchmove', function(event){
    event.stopPropagation();
});
//全局阻止移动,防止页面被拽
$(document).on('touchmove', function(event){
    //$('#J_page-box-1').prepend('
move body
'); event.preventDefault(); });

5、查看表大小排序
SELECT TABLE_NAME,DATA_LENGTH+INDEX_LENGTH as SIZE,TABLE_ROWS,concat(round(data_length/1024/1024),’MB’) as data FROM information_schema.TABLES WHERE TABLE_SCHEMA=’child’ order by SIZE desc limit 10;

无标签信息
0