工作中遇到的CSS问题或JS技巧rem计算rem等比缩小放样方案1@mediascreenand(min-width:320px){html{font-size:50px;}}@mediascreenand(min-width:360px){html{font-size:56.25px;}}@mediascreenand(min-width:375px){html{font-size:58.59375px;}}@mediascreenand(min-宽度:400px){html{font-size:62.5px;}}@mediascreenand(min-width:414px){html{font-size:64.6875px;}}@mediascreenand(min-width:440px){html{font-size:68.75px;}}@mediascreenand(min-width:480px){html{font-size:75px;}}@mediascreenand(min-width:520px){html{font-大小:81.25px;}}@media屏幕和(最小宽度:560px){html{font-size:87.5px;}}@media屏幕和(最小宽度:600px){html{font-size:93.75px;}}@media屏幕和(最小宽度:640px){html{font-size:100px;}}@media屏幕和(最小宽度:680px){html{font-size:106.25px;}}@media屏幕和(最小宽度:720px){html{font-size:112.5px;}}@media屏幕和(最小宽度:760px){html{font-size:118.75px;}}@media屏幕和(min-宽度:800px){html{font-size:125px;}}@mediascreenand(min-width:960px){html{font-size:150px;}}方案2@mediascreenand(min-width:320px){html{font-size:312.5%;}}@mediascreenand(min-width:360px){html{font-size:351.5625%;}}@mediascreenand(min-width:375px){html{font-size:366.211%;}}@mediascreenand(min-width:400px){html{font-size:390.625%;}}@mediascreenand(min-width:414px){html{font-size:404.2969%;}}@mediascreenand(min-width:440px){html{font-size:429.6875%;}}@mediascreenand(min-width:480px){html{font-size:468.75%;}}@mediascreenand(min-width:520px){html{font-size:507.8125%;}}@mediascreenand(min-width:560px){html{font-size:546.875%;}}@mediascreenand(min-width:600px){html{font-size:585.9375%;}}@mediascreenand(min-width:640px){html{font-size:625%;}}@mediascreenand(min-宽度:680px){html{font-size:664.0625%;}}@mediascreenand(min-width:720px){html{font-size:703.125%;}}@mediascreenand(min-width:760px){html{font-size:742.1875%;}}@mediascreenand(min-width:800px){html{font-size:781.25%;}}@mediascreenand(min-width:960px){html{font-size:937.5%;}}方案3vardesignWidth=640,rem2px=100;document.documentElement.style.fontSize=((window.innerWidth/designWidth)*rem2px)+'px';方案4vardesignWidth=640,rem2px=100;document.documentElement.style.fontSize=((((window.innerWidth/designWidth)*rem2px)/16)*100)+'%';居中方法绝对与tranform.parent{position:relative;}.child{position:absolute;左:50%;顶部:50%;transform:translate(-50%,-50%);}flex.parent{显示:flex;证明内容:居中;align-items:center;}具有定位值的绝对值。父母{位置:绝对;左:0;右:0;顶部:0;bottom:0;}文本换行。word-wrap{word-break:break-all;overflow:auto;}移动端1px问题div:after{content:"";位置:绝对;左:0;顶部:0;右:0;高度:1px;边框顶部:1pxsolid#D9D9D9;颜色:#D9D9D9;-webkit-transform-origin:00;-ms-transform-origin:00;变换原点:00;-webkit-transform:scaleY(0.5);:规模Y(0.5);transform:scaleY(0.5);}iOS部分使用弹性滚动效果iOS自带的全局滚动有内置弹性滚动,但是局部滚动没有iOS启动局部滚动并使用弹性滚动效果body{-webkit-overflow-scrolling:touch;}/*局部滚动domnode*/.scroll-el{overflow:auto;}将属性挂在body上可以避免很多奇怪的越界bug。什么情况下会触发越界?当全局滚动滚动到页面顶部(或底部)并继续向下(向上)滑动时,就会出现局部滚动。出现iOS解决方案:部分滚动:使用ScrollFix组件核心代码:if(startTopScroll<=0){elem.scrollTop=1}if(startTopScroll+elem.offsetHeight>=elem.scrollheight){elem.scrollTop=elem.scrollheight-elem.offsetHeight-1}注意:页面固定区域禁止touchmove默认事件android使用partialundong,会导致滚动条显示异常,滚动不流畅。Android下,推荐只使用全局滚动来平滑滚动页面。添加-webkit-overflow-scorlling:touch到iOS的主体。尝试使用部分滚动。iOS引入了ScrollFix来避免越界。Android下尽量使用全局滚动,尽量不要overflow:auto使用min-height:100%而不是height:100%iOS下有滚动条和position:absolute的节点不要设置背景色。输入唤起纯数字软键盘。使用input的type属性来唤起纯数字软键盘。
