我們經(jīng)常適配的移動(dòng)端手機(jī)尺寸
1. 最小屏幕尺寸一般以iphone4為首選,注意iphone5/SE的width是一樣的
// 特殊場(chǎng)景,寫法不一,比如:
1. @media screen and (max-width:320px ){}
2. @media screen and (max-height:480px ){}
3. @media screen and (max-width:320px ) and (max-height:480px ){}
2. 還有就是iphone6/7/8
// 有時(shí)候我們只需要獲取width 或者h(yuǎn)eight 其中一個(gè)即可
1. @media screen and (max-width:375px ){}
2. @media screen and (max-height:667px ){}
3. 還有就是iphone6/7/8 Plus
1. @media screen and (max-width:414px ){}
2. @media screen and (max-height:736px ){}
4. iPhone XS: 5.8 英寸
@media only screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3){}
5. iPhone XR: 6.1 英寸
@media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2){}
6. iPhone XS Max: 6.5 英寸
@media only screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3){}
@media screen and (max-width:768px ) {
width: 100%;
transform: scale(0.8) translateZ(0)
}
獲取屏幕尺寸
// 屏幕可以大小
screen.availWidth+"/"+screen.availHeight
// 屏幕分辨率
screen.width+"/"+screen.height
// 網(wǎng)頁(yè)可見區(qū)域
document.body.clientWidth +"/"+ document.body.clientHeight
// 網(wǎng)頁(yè)可見區(qū)域(包括邊線的寬)
document.body.offsetWidth +"/"+ document.body.offsetHeight
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。