W3C CSS文档 | 7.Media types 自己的学习笔记&翻译,欢迎指正

date
Mar 4, 2021
slug
css-w3c-media-types
status
Published
tags
CSS
type
Post
summary
7 Media types 自己的学习笔记&翻译

introduction to media types

  • css一个重要的特性怎样指定文档在不同的媒体之中呈现。在屏幕,纸上,盲文设备上,等等。
  • 确定的css样式只是为了确定的呈现方式。然而,在不同的媒体类型xss可能分享属性。但是这些属性需要指定不同的值,例如在纸上和屏幕都有font-size属性,但是在纸上字体就要大一些。所以css需要应用于特定的media types。

Specifying media-dependent style sheets

有两个方式来指定依赖的媒体类型
  • 用@media或者@important rules
    • @imporant url ("fancyfonts.css") screen; @media print { /*style sheet for print goes here*/ }
  • 用document language(过时了)
    • <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"> <HTML> <HEAD> <TITLE>Link to a target medium</TITLE> <LINK REL="stylesheet" TYPE="text/css" MEDIA="print, handheld" /*就是这一句*/HREF="foo.css"> </HEAD> <BODY> <P>The body... </BODY> </HTML>

the @media rule

@media rule 指定一组语句(用大括号分隔)的目标媒体类型(用逗号分隔)。根据4.1.7的“规则集、声明块和选择器”和4.2的“处理规则”,无效语句必须被忽略。解析错误。”@media构造允许在同一个样式表中使用不同媒体的样式表规则

recognized media types

css media type 反映了对于相关属性有意义的目标设备
  • all
    • Suitable for all devices.对于每个设备使用
  • braille
    • Intended for braille tactile feedback devices.为盲人打造的触觉反馈设备
  • embossed
    • Intended for paged braille printers.用于每页的盲文打印
  • handheld
    • Intended for handheld devices (typically small screen, limited bandwidth) 为了手持设备设计(被宽度限制,是典型的小屏幕)
  • print
    • Intended for paged material and for documents viewed on screen in print preview mode. 为了每页的材质和在屏幕打印预览的模型。
  • projection
    • Intended for projected presentations, for example projectors. 为了项目展示
  • screen
    • Intended primarily for color computer screens.首要地为有色彩的电脑屏幕设计
  • speech
    • Intended for speech synthesizers. 语音合成器?
      css2有个叫做paged media的。
  • tty
    • Intended for media using a fixed-pitch character grid (such as teletypes, terminals, or portable devices with limited display capabilities). Authors should not use pixel units with the "tty" media type.用于使用固定间距字符网格的媒体(如电传打字机、终端或显示能力有限的便携式设备)。作者不应该在“tty”媒体类型中使用像素单元。
  • tv
    • Intended for television-type devices (low resolution, color, limited-scrollability screens, sound available).为了电视(低分辨率……)
  • 媒体类型名是感知不灵敏的
  • 媒体类型是互斥的,UA在呈现文档时只能支持一种媒体类型。然而,UA可以在不同的画布上使用不同的媒体类型。例如,一个文档可能(同时)在一个画布上以“屏幕”模式显示,在另一个画布上以“打印”模式显示。

    media groups

    因为每种属性都对应了不同的媒体类型,所以就每个类型列出的“适用的“media type”是一个列表。
    • continuous or paged.
    • visual, audio, speech, or tactile.
    • grid (for character grid devices), or bitmap.
    • interactive (for devices that allow user interaction), or static (for those that do not).
    • all (includes all media types)
    Media Types
    Media Groups
    continuous/paged
    visual/audio/speech/tactile
    grid/bitmap
    interactive/static
    braille
    continuous
    tactile
    grid
    both
    embossed
    paged
    tactile
    grid
    static
    handheld
    both
    visual, audio, speech
    both
    both
    print
    paged
    visual
    bitmap
    static
    projection
    paged
    visual
    bitmap
    interactive
    screen
    continuous
    visual, audio
    bitmap
    both
    speech
    continuous
    speech
    N/A
    both
    tty
    continuous
    visual
    grid
    both
    tv
    both
    visual, audio
    bitmap
    both

    © dana 2023 - 2025