继续浏览精彩内容
慕课网APP
程序员的梦工厂
打开
继续
感谢您的支持,我会继续努力的
赞赏金额会直接到老师账户
将二维码发送给自己后长按识别
微信支付
支付宝支付

移动端开发日常问题汇总(持更)

qq_邪风曲_0
关注TA
已关注
手记 2
粉丝 0
获赞 2

1、视口约束

<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-
scale=1.0, user-scalable=0">

2、rem布局

//rem适配
function changeRootFont() {
    var htmlE = document.getElementsByTagName('html')[0];
    var bodyWidth = document.documentElement.clientWidth || document.body.clientWidth;
    var designWidth = 750, rem2px = 100;
    htmlE.style.fontSize = ((bodyWidth / designWidth) * rem2px) + 'px';
}
changeRootFont();
window.addEventListener('resize', changeRootFont,false);

3、用scss mixin定义flex

@mixin flex($justify:flex-start,$align:center){
    display: -webkit-flex;
    display: -webkit-box;
    display: flex;
    -webkit-justify-content:$justify;
    justify-content:$justify;
    -webkit-align-items:$align;
    align-items:$align;
}

4、iconfont的使用,先全局引入iconfont-css样式,随后只需要引入样式图标类名就行

<link rel="stylesheet" href="//at.alicdn.com/t/font_280648_z7tocj59bqr.css">
<router-link to="/personalCenter"><span>我</span><span class="iconfont icon-gerenzhongxin"></span></router-link>

5、移动端1px

@mixin line1px($color:#ddd){
    position: relative;
    &:after{ 
        content: " "; 
        position: absolute; 
        left: 0; 
        bottom: 0; 
        width: 100%; 
        height: 1px; 
        background-image: -webkit-linear-gradient(0deg, $color 50%, transparent 50%); 
        background-image: -moz-linear-gradient(0deg, $color 50%, transparent 50%); 
        background-image: -ms-linear-gradient(0deg, $color 50%, transparent 50%); 
        background-image: -o-linear-gradient(0deg, $color 50%, transparent 50%); 
        background-image: linear-gradient(0deg, $color 50%, transparent 50%);
    }
}
打开App,阅读手记
0人推荐
发表评论
随时随地看视频慕课网APP