我想使用這裏討論的CSS3媒體查詢技術...使用CSS3媒體時,減少HTTP請求查詢
http://www.stuffandnonsense.co.uk/blog/about/hardboiled_css3_media_queries
如果我從下面抓住代碼和一個新的頁面上運行使用某種模擬器將自己標識爲具有小屏幕的設備(例如,Device Central或Protofluid)我可以在Charles中看到,即使正確拾取了樣式表,仍然會爲每個CSS文件提出請求,這是正常行爲?
<link rel="stylesheet" href="smartphone.css" media="only screen and (min-device-width : 320px) and (max-device-width : 480px)">
<link rel="stylesheet" href="smartphone-landscape.css" media="only screen and (min-width : 321px)">
<link rel="stylesheet" href="smartphone-portrait.css" media="only screen and (max-width : 320px)">
<link rel="stylesheet" href="ipad.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1024px)">
<link rel="stylesheet" href="ipad-landscape.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : landscape)">
<link rel="stylesheet" href="ipad-portrait.css" media="only screen and (min-device-width : 768px) and (max-device-width : 1024px) and (orientation : portrait)">
<link rel="stylesheet" href="widescreen.css" media="only screen and (min-width : 1824px)">
<link rel="stylesheet" href="iphone4.css" media="only screen and (-webkit-min-device-pixel-ratio : 1.5), only screen and (min-device-pixel-ratio : 1.5)">
因此,您是否建議提供單個CSS文件「media-queries.css」,並在其中使用媒體查詢塊而不是多個鏈接元素? – danjah 2012-04-12 21:08:18
@Danjah這不是一個完全相同的問題 - 所有這些答案都是說所有的CSS都會以任何方式下載 – robertc 2012-04-12 22:36:25
我想問的是,我的問題與減少http請求的次數有關,「有需要」。 – danjah 2012-04-12 22:54:49