您的当前位置:首页css单位简单介绍_html/css_WEB-ITnose

css单位简单介绍_html/css_WEB-ITnose

2020-11-27 来源:飒榕旅游知识分享网

摘要

这个css3模块描述了css属性的常用值和单位和在css属性定义时使用它们的语法。
css是一种用于描述结构化文档(如 HTML 和 xml)的呈现语言,常见于在屏幕上,在纸上,演讲等。

  • Introduction
  • The value definition field of each CSS property can contain keywords,
    data types (which appear between < and >), and information on how they
    can be combined. Generic data types ( being the most widely
    used) that can be used by many properties are described in this
    specification, while more specific data types (e.g., )
    are described in the corresponding modules.

    每个css属性可以包括keywords, data types(出现在<和>中间),它们如何组合。通用数据类型(被最广泛使用)被最多属性描述 而其他一些更为特定的数据类型(如< spacing-limit >)描述了相应的模块。

    1.1. Module Interactions

    This module replaces and extends the data type definitions in [CSS21]
    sections 1.4.2.1, 4.3, and A.2.

    模块的交互

    这个模块取代[css21]的相关章节

  • Value Definition Syntax
  • The syntax described here is used to define the set of valid values
    for CSS properties. A property value can have one or more components.

    值定义语法
    这里描述的语法用于定义一组有效值的CSS属性。属性值可以有一个或多个组件

    2.1. Component value types

    Component value types are designated in several ways:

  • keyword values (such as auto, disc, etc.), which appear literally,
    without quotes (e.g. auto)
  • basic data types, which appear between < and > (e.g., ,
    , etc.).
  • types that have the same range of values as a property bearing the
    same name (e.g., <‘border-width’>, <‘background-attachment’>, etc.).
    In this case, the type name is the property name (complete with
    quotes) between the brackets. Such a type does not include CSS-wide
    keywords such as inherit.
  • non-terminals that do not share the same name as a property. In this
    case, the non-terminal name appears between < and >, as in
    . Notice the distinction between and
    <‘border-width’>: the latter is defined as the value of the
    border-width property, the former requires an explicit expansion
    elsewhere. The definition of a non-terminal is typically located
    near its first appearance in the specification.
  • 组件值类型
    组件值类型指定的在几个方面

  • 关键词(如 auto, disc, etc.)
  • 基本数据类型 出现在<和》
  • 类型有相同的值作为属性轴承相同的名称 既然这样 类型的名字是属性名
  • 非终结符,不共享相同的名称作为财产 在这种情况下
  • Some property value definitions also include the slash (/), the comma
    (,), and/or parentheses as literals. These represent their
    corresponding tokens. Other non-keyword literal characters that may
    appear in a component value, such as “+”, must be written enclosed in
    single quotes.

    一些属性值定义也包括 (/) 逗号 (,)

    Commas specified in the grammar are implicitly omittable in some circumstances, when used to separate optional terms in the grammar. Within a top-level list in a property or other CSS value, or a function’s argument list, a comma specified in the grammar must be omitted if:

    For example, if a function can accept three arguments in order, but
    all of them are optional, the grammar can be written like:
    example(first? , second? , third? )

    如果一个函数需要三个参数,可以写成这样
    example(first? , second? , third? )

    Given this grammar, writing example(first, second, third) is valid, as
    is example(first, second) or example(first, third) or example(second).
    However, example(first, , third) is invalid, as one of those commas
    are no longer separating two options; similarly, example(,second) and
    example(first,) are invalid. example(first second) is also invalid, as
    commas are still required to actually separate the options.

    If commas were not implicitly omittable, the grammar would have to be
    much more complicated to properly express the ways that the arguments
    can be omitted, greatly obscuring the simplicity of the feature.

    正确的
    example(first, second) or example(first, third) or example(second)
    错误的
    example(first, , third) is invalid, example(,second) and example(first,)

    All CSS properties also accept the CSS-wide keyword values as the sole
    component of their property value. For readability these are not
    listed explicitly in the property value syntax definitions. For
    example, the full value definition of border-color is {1,4} |
    inherit | initial | unset (even though it is listed as {1,4}).

    所有属性也接受css-wide关键词值作为组件的属性。为了便于阅读 这些都不是明确列出的属性值语法定义。
    比如 border-color 的值定义是 {1,4} | inherit | initial | unset

    2.2. Component value combinators

    Component values can be arranged into property values as follows:

  • Juxtaposing components means that all of them must occur, in the
    given order.
  • A double ampersand (&&) separates two or more components, all of
    which must occur, in any order.
  • A double bar (||) separates two or more options: one or more of them
    must occur, in any order.
  • A bar (|) separates two or more alternatives: exactly one of them
    must occur.
  • Brackets ([ ]) are for grouping.
  • 组件值被安排到组件值必须遵循
    所有组件遵循顺序
    && 分离两个或多个组件
    || 分离两个或多个options
    | 分离两个或多个替代选择
    [] 分组

    Juxtaposition is stronger than the double ampersand, the double
    ampersand is stronger than the double bar, and the double bar is
    stronger than the bar. Thus, the following lines are equivalent:

    a b | c || d && e f
    [ a b ] | [ c || [ d && [ e f ]]]

    并列(e f) > && > || > |

    For re-orderable combinators (||, &&), ordering of the grammar does
    not matter: components in the same grouping may be interleaved in any
    order. Thus, the following lines are equivalent:

    a || b || c
    b || a || c

    || && 中的内容顺序并不重要

    2.3. Component value multipliers

    Every type, keyword, or bracketed group may be followed by one of the
    following modifiers:

  • An asterisk (*) indicates that the preceding type, word, or group
    occurs zero or more times.
  • A plus (+) indicates that the preceding type, word, or group occurs
    one or more times.
  • A question mark (?) indicates that the preceding type, word, or
    group is optional (occurs zero or one times).
  • A single number in curly braces ({A}) indicates that the preceding
    type, word, or group occurs A times.
  • A comma-separated pair of numbers in curly braces ({A,B}) indicates
    that the preceding type, word, or group occurs at least A and at
    most B times. The B may be omitted ({A,}) to indicate that there
    must be at least A repetitions, with no upper bound on the number of
    repetitions.
  • A hash mark (#) indicates that the preceding type, word, or group
    occurs one or more times, separated by comma tokens (which may
    optionally be surrounded by white space and/or comments). It may
    optionally be followed by the curly brace forms, above, to indicate
    precisely how many times the repetition occurs, like #{1,4}.
  • An exclamation point (!) after a group indicates that the group is
    required and must produce at least one value; even if the grammar of
    the items within the group would otherwise allow the entire contents
    to be omitted, at least one component value must not be omitted.
  • For repeated component values (indicated by *, +, or #), UAs must
    support at least 20 repetitions of the component. If a property value
    contains more than the supported number of repetitions, the
    declaration must be ignored as if it were invalid.

    每一类型、关键字或相等的组可能是紧随其后的是一个修饰符

  • 星号(*)表示前面出现的type,word,或group出现零次或多次
  • 加号(+)表示前面出现的type,word,或group出现1次或多次
  • 问号(?)表明前面的type,word,或group是可选的(发生零个或一次)
  • 花括号带数字({A})表明前面的type,word,或group出现A次
  • 花括号带数字({A,B})表明前面的type,word,或group出现A到B次,
    花括号带数字({,B})表明前面的type,word,或group出现1到B次
  • 散列马克(#)表明前面的类型,单词,或组发生一次或多次
  • 感叹号(!),一组表明,集团要求必须至少产生一个值,即使语法组内的物品会让整个内容省略,至少一个组件值不能省略。
  • 感叹号(!),一组表明,集团要求必须至少产生一个值,即使语法组内的物品会让整个内容省略,至少一个组件值不能省略。

    2.4. Combinator and Multiplier Patterns

    There are a small set of common ways to combine multiple independent
    component values in particular numbers and orders. In particular, it’s
    common to want to express that, from a set of component value, the
    author must select zero or more, one or more, or all of them, and in
    either the order specified in the grammar or in any order.

    All of these can be easily expressed using simple patterns of
    combinators and multipliers:
    Note that all of the "any
    order" possibilities are expressed using combinators, while the "in
    order" possibilities are all variants on juxtaposition.

    一个属性值可能有多个组件组成

    2.5. Component values and white space

    Unless otherwise specified, white space and/or comments may appear
    before, after, and/or between components combined using the above
    combinators and multipliers.

    显示全文