螢幕大小適配,rem與em的區別適用
阿新 • • 發佈:2018-12-23
1、小於某個寬度時固定
@media screen and (max-width:1372px){
body{
min-width: 1344px;
}
}
2、移動端適配
@media screen and (min-width:321px) and (max-width:375px){html,body {font-size:11px}}
@media screen and (min-width:376px) and (max-width:414px){html,body {font-size:12px}}
@media screen and (min-width:415px) and (max-width:639px){html,body{font-size:15px}}
@media screen and (min-width:640px) and (max-width:719px){html,body{font-size:20px}}
@media screen and (min-width:720px) and (max-width:749px){html,body{font-size:22.5px}}
@media screen and (min-width:750px) and (max-width:799px){html,body{font-size:23.5px}}
@media screen and (min-width:800px){html,body{font-size:25px}}
em:一般都是以<body>的“font-size”為基準。相對於父元素的屬性而計算的.進行任何元素設定,都有可能需要知道他父元素的大小。
rem:相對於根元素<html>設定字型大小,只需要在根元素確定一個參考值。
@media screen and (max-width:1372px){
body{
min-width: 1344px;
}
}
2、移動端適配
@media screen and (min-width:321px) and (max-width:375px){html,body {font-size:11px}}
@media screen and (min-width:376px) and (max-width:414px){html,body {font-size:12px}}
@media screen and (min-width:415px) and (max-width:639px){html,body{font-size:15px}}
@media screen and (min-width:640px) and (max-width:719px){html,body{font-size:20px}}
@media screen and (min-width:720px) and (max-width:749px){html,body{font-size:22.5px}}
@media screen and (min-width:750px) and (max-width:799px){html,body{font-size:23.5px}}
@media screen and (min-width:800px){html,body{font-size:25px}}
em:一般都是以<body>的“font-size”為基準。相對於父元素的屬性而計算的.進行任何元素設定,都有可能需要知道他父元素的大小。
rem:相對於根元素<html>設定字型大小,只需要在根元素確定一個參考值。