@media screen有兩種種使用方式:
1、在link中使用media 屬性判斷屏幕寬高,可以引用不同的css文件:
<link rel="stylesheet" type="text/css" href="style.css" media="screen and (min-width: 800px)">
2、寫在樣式文件中,通過@media screen判斷屏幕寬高適應不同分辨率。在不同的寬高下寫不同的樣式類屬性
/*適應寬度*/ @media screen and (max-width: 1365px) { body { font-size: 10px; } } @media screen and (min-width: 1366px) and (max-width: 1599px) { body { font-size: 12px; } } @media screen and (min-width: 1600px) and (max-width: 1919px) { body { font-size: 14px; } } @media screen and (min-width: 1920px) { body { font-size: 16px; } } /*適應高度*/ @media screen and (min-height: 901px) and (max-height: 1080px){ body { font-size: 16px; } } @media screen and (min-height: 800px) and (max-height: 900px){ body { font-size: 16px; } }