分类
svg

CSS语法解析系列~font

font

font = [[<font-style> || <font-variant-css2> || <font-stretch-css3>? <font-size> [ / <line-height>]? <font-family> ]? | caption | icon |menu | message-box | small-caption | status-bar

<font-style>

它的默认值是normal

font-style = normal | italic | oblique <angle>?

如果使用简写,那么它必须要有font-family不然是无效的

oblique后面的<angle>如果使用大概率无效

<font-family>

font-family = [<family-name> | <generic-family>]#

<family-name>

通用字体名称

<font-variant-css2>

font-variant-css2 = [normal | small-caps]

small-caps是小型大写字母的意思

涉及的属性名有font-synthesis-weight,font-synthesis-style,font-synthesis-small-caps,font-synthesis

<font-stretch-css3>

允许你使文字变宽或者变窄

font-stretch-css3 = [normal | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded ]

属性名是 font-stretch,下面的属性值很可能没有卵用

ultra-condensed:使文本窄的不能再窄,大概率无效果

extra-condensed:紧缩程度第二大的字体

condensed:紧缩程度第三大的字体

semi-condensed:紧缩程度最小的字体

normal:默认值

semi-expanded:使文本稍微变窄

expanded:变得更宽

extra-expanded:变得最宽

<font-size>

font-size = <absolute-size> | <relative-size> | <length-percentage> | math

默认值为absolute-size的medium

<absolute-size> = [xx-small | x-small | small | medium | large | x-large | xx-large]

这些值的大小由用户控制

<relative-size> = [larger | smaller]

<font-weight>

font-weight = normal | bold | bolder | lighter | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900

默认值:normal

caption

表格头

icon

图标字体,大小16px,会使英文紧凑一点,font-weight大一点

menu

使用系统字体,可以给用户一种熟悉的感觉

message-box

dialog中使用的字体

small-caption

小标题

status-bar

windows电脑的状态栏

分类
CSS

CSS语法解析系列~Background

background

background = [<bg-layer>#,]? <final-bg-layer>

<bg-layer>

bg-layer = <bg-img> || <bg-position> [ / <bg-size>]? || <repeat-style> || <attachment> || <box> || <box>

<final-bg-layer>

final-bg-layer= <background-color> || <bg-image> || <bg-position> [/ <bg-size>]? || <repeat-style> || <attachment> || <box> || <box>

<attachment>

这是背景图单独属性 background-attachment,它的默认值是scroll,表现为在根滚动条下,滚动的时候图片也会滚动,但是如果在元素中,这个背景就会固定住不会随内容滚动。这与local的区别是,local在元素中有滚动条的话,背景会随元素的内容滚动。还有一个值是fixed,它就像贴在根元素上一样,但是显示的大小还是根据元素决定,可以使用padding-top实现高度与宽度与图片比例一致,但总体来说整个可视区域的高度都可以显示到,在移动端适合高比宽大的图片background-size取100% auto,但是两侧显示不到。在PC端适合宽比高大的图片background-size取auto 100%,但是上下显示不全。这已是最大化显示内容的方案,我认为显示不全这一缺点也是这种技术不是非常流行的原因

<box>

box=border-box | padding-box | content-box

它的默认值为border-box,但是对于color来说,它确实是真正的border-box,但是对于图片来说它的初始值是padding-box。

它的属性值是background-clip,但是background-clip中还有一个text的属性,这个属性能够把背景裁剪到字体。

<bg-image>

<bg-image>=<image> | none

<image> = <url> | <gradient>

它的属性名叫做background-image,默认值是none

<bg-position>

它的属性名是background-position,默认值是0% 0%,

bg-position = [top | left | right | bottom | <length-percentage>]

| [left | center | right | <length-percentage>] [top | center | bottom | <length-percentage>]

| [center | [left | right] <length-percentage>] [center | [top | bottom] <length-percentage>]

这里可以找到一种不常用的用法,background-position:right 20px bottom 20px

<bg-size>

属性名是background-size,默认值 auto,代表源图片大小

bg-size=[<length-percentage [0,+无穷]> | auto]{1,2} | cover | contain

<repeat-style>

repeat-style的属性名是background-repeat,默认值是repeat

repeat-style = repeat-x | repeat-y | [repeat | no-repeat | round | space]{1,2}

当有两个值是第一个代表水平方向,第二个代表垂直方向

使用round,如果background-size是15% 15%,它铺六个是90%,铺七个是105,则会铺设7个然后缩小一点,并全部铺完。

如果background-size是16% 16%,它铺六个是96%,铺七个是112%,则他会铺六个,然后撑开一点。

使用space,保持原本的大小,会留出空隙

分类
CSS

CSS语法解析系列~mask-image

mask-image

mask-image = <mask-reference>#

#

标识1个或多个,如果是多个需要用逗号分割

mask-reference

mask-reference = none | <image> | <mask-source>

<image>

image = <url> | <gradient>

<gradient>

gradient = <linear-gradient()> | <repeating-linear-gradient()> | <radial-gradient()> | <repeating-radial-gradient()>

linear-gradient()

linear-gradient() = linear-gradient([angle | to <side or corner>]?, <color-stop-list>)

<color-stop-list>

color-stop-list = <linear-color-stop>,[<linear-color-hint>?,<linear-color-stop>]#

<linear-color-hint>

linear-color-hint = <length-percentage>

linear-color-hint的作用应该是延续上一段的颜色

repeating-linear-gradient()

属性值与linear-gradient相同,但是会循环

radial-gradient

radial-gradient() = radial-gradient([<ending-shape> || <size>]?[at <position>]?,<color-stop-list>)

<size>

closest-side

最近的边

farthest-side

最远的边

closest-corner

最近的角

farthest-corner

最远的角

分类
CSS

CSS语法解析系列~border-image

border-image = <‘border-image-source’> || <‘border-image-slice’> [ / <‘border-image-width’> | / <‘border-image-width’>? / <‘border-image-outset’> ]? || <‘border-image-repeat’>

||

或组合符,各部分必须出现一个但是可以不按顺序出现,比如说有三个,则最少要出现1个,在这个例子中,<border-image-source>和<border-image-slice>只要要有一个出现。

<>

尖括号内的东西叫做数据类型,它的作用是表明里面的东西是一个数据类型

[]

分组,通常需要使用限定词时会顺带使用分组,比如分组中的内容会同时出现一次或0次,则要在分组的右边加入?

|

互拆组合符,标识多个部分只能取一个

限定词,标识1个或0个

/

当出现该符号时说明左右两边具有相同或部分相同的数据结构,当然在简写时该符号是需要保留的,这是与其他大部分标识符的不同之处

<border-image-source>

border-image-source = none | <image>

<border-image-slice>

border-image-slice = [<number [0,∞]> | <percentage [0,∞]>]{1,4} && fill?

&&

各部分必须出现,但是可以不按顺序出现

<border-image-width>

border-image-width=[ <length-percentage [0,∞]> | <number [0,∞]> | auto ]{1,4}

其中border-image-slice与border-image-width在一起时是无法分清属性值是属于哪个属性的,所以border-image-width需要加上/

<border-image-outset>

border-image-outset=[ <length [0,∞]> | <number [0,∞]> ]{1,4}

该属性的属性值又与border-image-slice,border-image-width冲突所以可能会出现这样的border-image值

border-image:20% // 2px repeat

border-image-repeat

border-image-repeat = [ stretch | repeat | round | space ]{1,2}