css3媒體查詢

  1. 語(yǔ)法結(jié)構(gòu)及用法:
    @media 設(shè)備名 only (選取條件) not (選取條件) and(設(shè)備選取條件),設(shè)備二{sRules}
  2. 實(shí)際應(yīng)用一 判斷設(shè)備橫豎屏:
/* 這是匹配豎屏的狀態(tài),豎屏?xí)r的css代碼 */@media all and (orientation :portrait){}  ```
3. 實(shí)際應(yīng)用二 判斷設(shè)備類型:
```@media X and (min-width:200px){} X為設(shè)備類型》比如print/screen/TV等等```
4. 實(shí)際應(yīng)用三 判斷設(shè)備寬高:
```/* 寬度大于600px小于960之間時(shí),隱藏footer結(jié)構(gòu) */@media all and (min-height:640px) and (max-height:960px){    footer{display:none;}} ```
5. 實(shí)際應(yīng)用四 判斷設(shè)備像素比:
```/* 像素比為1時(shí),頭部顏色為綠色 */     
.header { background:red;display:block;}或@media only screen and (-moz-min-device-pixel-ratio: 1), only screen and (-o-min-device-pixel-ratio: 1), only screen and (-webkit-min-device-pixel-ratio: 1), only screen and (min-device-pixel-ratio:1) {.header{background:green;} }```
``` /* 像素比為1.5時(shí),頭部背景為紅色 */        
@media only screen and (-moz-min-device-pixel-ratio: 1.5), only screen and (-o-min-device-pixel-ratio: 1.5), only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-device-pixel-ratio:1.5) {.header{background:red;} }```
```/*像素比為2,頭部背景為藍(lán)色 */    
@media only screen and (-moz-min-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2), only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min-device-pixel-ratio:2){.header{background:blue;} }  ```
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 能夠讓網(wǎng)站針對(duì)不同的瀏覽器和設(shè)備呈現(xiàn)不同顯示效果 引入媒體查詢 媒體查詢寫在CSS樣式代碼的最后,CSS是層疊樣式...
    LYF閑閑閑閑閱讀 536評(píng)論 0 3
  • -:Internet Explorer CSS :- SpecialPurpose _::selection, :...
    彌果閱讀 1,418評(píng)論 0 1
  • 問(wèn)題的由來(lái) 手機(jī)屏幕的分辨率差異很大。 iphone4:320×480 iphone6:375×667 H5 網(wǎng)頁(yè)...
    尚山夏香閱讀 2,591評(píng)論 0 1
  • 1、垂直對(duì)齊 如果你用CSS,則你會(huì)有困惑:我該怎么垂直對(duì)齊容器中的元素?現(xiàn)在,利用CSS3的Transform,...
    kiddings閱讀 3,297評(píng)論 0 11
  • 不管黑夜的迷離 或是烏云的沉郁 我,仰望 即使星空一片沉寂 我了解 無(wú)論是非變換 無(wú)論滄海覆轍 那些依在 那心依在
    愛貓的旅行狗閱讀 222評(píng)論 0 2

友情鏈接更多精彩內(nèi)容