舉例:css
@media screen and (min-width: 769px) and (max-width: 979px) { .w { width: 750px; } .top_nav ul li:first-child { display: none; } .nav ul li:last-child { display: none; } .bottom_cards .cards .item { width: 49%; } .bottom_cards .cards:after { display: none; } }
/* 設計圖寬度爲640px, 計算font-size的方法爲: 要適配的屏幕尺寸/設計圖尺寸*默認下的文字大小 即: 320/640*32 = 16(px) */ @media only screen and (width: 320px) { html { font-size: 16px; } } /* 即: 360/640*32 = 18(px) */ @media only screen and (width: 360px) { html { font-size: 18px; } } /* 即: 375/640*32 = 18.75(px) */ @media only screen and (width: 375px) { html { font-size: 18.75px; } } /* 即: 414/640*32 = 20.7(px) */ @media only screen and (width: 414px) { html { font-size: 20.7px; } }