HTML 參考手冊
針對兩種不同媒介類型(屏幕和打?。┑膬蓚€不同的樣式表:
所有主流瀏覽器都支持 media 屬性。
media 屬性規(guī)定目前資源是為何種媒介/設備優(yōu)化的。
該屬性大多用在為不同媒介類型規(guī)定不同樣式的 CSS 樣式表。
提示:該屬性可以接受多個值。
無。
值 | 描述 |
---|---|
and | 規(guī)定 AND 操作符。 |
not | 規(guī)定 NOT 操作符。 |
, | 規(guī)定 OR 操作符。 |
值 | 描述 |
---|---|
all | 默認。適應所有設備。 |
aural | 語音合成器。 |
braille | 盲人用點字法反饋設備。 |
handheld | 手持設備(小屏幕、有限的帶寬)。 |
projection | 放映機。 |
打印預覽模式 / 打印頁。 | |
screen | 計算機屏幕(默認值)。 |
tty | 電傳打字機以及使用等寬字符網(wǎng)格的類似媒介。 |
tv | 電視類型設備(低分辨率、有限的屏幕翻滾能力)。 |
值 | 描述 |
---|---|
width |
規(guī)定目標顯示區(qū)域的寬度。 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (min-width:500px)" |
height |
規(guī)定目標顯示區(qū)域的高度。 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (max-height:700px)" |
device-width |
規(guī)定目標顯示器/紙張的寬度。 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (device-width:500px)" |
device-height |
規(guī)定目標顯示器/紙張的高度。 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (device-height:500px)" |
orientation |
規(guī)定目標顯示器/紙張的方向。 可能的值:"portrait" or "landscape" 例子:media="all and (orientation: landscape)" |
aspect-ratio |
規(guī)定目標顯示區(qū)域的寬度/高度比 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (aspect-ratio:16/9)" |
device-aspect-ratio |
規(guī)定目標顯示器/紙張的 device-width/device-height 比率 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (aspect-ratio:16/9)" |
color |
規(guī)定目標顯示器的 bits/color 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (color:3)" |
color-index |
規(guī)定目標顯示器可以處理的顏色數(shù)。 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (min-color-index:256)" |
monochrome |
規(guī)定單色幀緩沖中的 bits/pixel。 可使用 "min-" 和 "max-" 前綴。 例子:media="screen and (monochrome:2)" |
resolution |
規(guī)定目標顯示器/紙張的像素密度 (dpi 或 dpcm)。 可使用 "min-" 和 "max-" 前綴。 例子:media="print and (resolution:300dpi)" |
scan |
規(guī)定 tv 顯示器的掃描方式。 可能的值:"progressive" 和 "interlace"。 例子:media="tv and (scan:interlace)" |
grid |
規(guī)定輸出設備是否是網(wǎng)格或位圖。 可能的值:"1" 為網(wǎng)格,否則為 "0"。 例子:media="handheld and (grid:1)" |