RESPONSIVE WEB DESIGN
Media Queries
<meta name="viewport" content="width=device-width; initial-scale=1.0" />方法1:全部的使用者都會載入這裡的 CSS。
@media screen and (min-width: 1200px) {
// 如果使用者之視窗寬度 >= 1200px,將會再載入這裡的 CSS。
}
@media screen and (min-width: 768px) and (max-width: 979px) {
// 如果使用者之視窗寬度介於 768px ~ 979px,將會再載入這裡的 CSS。
}
@media screen and (max-width: 767px) {
// 如果使用者之視窗寬度 <= 768px,將會再載入這裡的 CSS。
}
@media screen and (max-device-width: 480px) {
// 如果使用者之裝置寬度 <= 480px,將會再載入這裡的 CSS。
}
方法2:
<link rel="stylesheet" type="text/css" href="all.css" media="screen">
<link rel="stylesheet" type="text/css" href="a.css" media="screen and (max-width: 767px)">
<link rel="stylesheet" type="text/css" href="b.css" media="screen and (min-width: 768px) and (max-width: 979px)">
<link rel="stylesheet" type="text/css" href="c.css" media="screen and (min-width: 1200px)">
<link rel="stylesheet" type="text/css" href="d.css" media="screen and (max-device-width: 480px)">
文章出處:http://fundesigner.net/css3-media-queries/
留言
張貼留言