1.@custom-media --sm (min-width: 576px);
@custom-media --md (min-width: 768px);@custom-media --lg (min-width: 992px);@custom-media --xl (min-width: 1200px);.info-header { @media (--md) { width: 50%;// ipad } margin-left: auto; margin-right: auto; border-bottom: 1pxsolid#dddddd;//手机}2. Screen Fitting
Dynamically write font-size based on different screens, with REM as the width unit, fixed layout viewport.
<meta name="viewport" content="width=device-width,initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no">
To 640px Design and 750px of visual manuscript, NetEase such treatment:
var width = document.documentElement.clientWidth; // 屏幕的布局视口宽度var rem = width / 7.5; // 750px设计稿将布局视口分为7.5份var rem = width / 6.4; // 640px设计稿将布局视口分为6.4份
This way, whether it is a 750px design or 640px design, 1rem equals the 100px on the design draft. Therefore, when PX converts REM:
rem = px * 0.01;
On the 750px design draft:
75px 对应 0.75rem, 距离占设计稿的10%;在ipone6上:width = document.documentElement.clientWidth = 375px;rem = 375px / 7.5 = 50px;0.75rem = 37.5px; (37.5/375=10%;占屏幕10%) 在ipone5上:width = document.documentElement.clientWidth = 320px;rem = 320px / 7.5 = 42.667px;0.75rem = 32px; (32/320=10%;占屏幕10%)
3、ipone适配ipad需要设置
-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation {
return (interfaceorientation = = uiinterfaceorientationportrait);
}
-(Nsuinteger) supportedinterfaceorientations{
return uiinterfaceorientationmaskportrait;
}
Will cause the iphone app to display on the ipad mini by default, click events, and the layout will be affected.
Mobile page with ipad?