移動端開發(fā)日常問題匯總(持更)
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" >
<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%);
}
}
點(diǎn)擊查看更多內(nèi)容
為 TA 點(diǎn)贊
評論
評論
共同學(xué)習(xí),寫下你的評論
評論加載中...
作者其他優(yōu)質(zhì)文章
正在加載中
感謝您的支持,我會繼續(xù)努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進(jìn)行掃碼打賞哦