CSS 参考CSS 选择器CSS 听觉参考手册CSS Web 安全字体组合CSS 动画CSS 单位CSS 颜色CSS 合法颜色值CSS 颜色名称CSS 颜色 十六进制值CSS 函数CSS align-content 属性CSS align-items 属性CSS align-self 属性CSS all 属性CSS 3 animation (动画) 属性CSS 3 animation-delay 属性CSS 3 animation-direction 属性CSS 3 animation-duration 属性CSS 3 animation-fill-mode 属性CSS 3 animation-iteration-countCSS 3 animation-name 属性CSS 3 animation-play-state 属性CSS 3 animation-timing-functionCSS 3 appearance 属性CSS 3 backface-visibility 属性CSS background 属性CSS background-attachment 属性CSS background-blend-mode 属性CSS 3 background-clip 属性CSS background-color 属性CSS background-image 属性CSS 3 background-origin属性CSS background-position 属性CSS background-repeat 属性CSS 3 background-size 属性CSS border 属性CSS border-bottom属性CSS border-bottom-color 属性CSS 3 border-bottom-left-radiusCSS 3 border-bottom-right-radiusCSS border-bottom-style 属性CSS border-bottom-width 属性CSS border-collapse 属性CSS border-color 属性CSS 3 border-image 属性CSS 3 border-image-outset 属性CSS 3 border-image-repeat 属性CSS 3 border-image-slice 属性CSS 3 border-image-source 属性CSS 3 border-image-width 属性CSS border-left 属性CSS border-left-color 属性CSS border-left-style 属性CSS border-left-width 属性CSS 3 border-radius 属性CSS border-right 属性CSS border-right-color 属性CSS border-right-style 属性CSS border-right-width 属性CSS border-spacing 属性CSS border-style 属性CSS border-top 属性CSS border-top-color 属性CSS 3 order-top-left-radius 属性CSS 3 border-top-right-radius 属性CSS border-top-style 属性CSS border-top-width 属性CSS border-width 属性CSS bottom 属性CSS 3 box-align 属性CSS 3 box-direction 属性CSS 3 box-flex 属性CSS 3 box-flex-group 属性CSS 3 box-lines 属性CSS 3 box-ordinal-group 属性CSS 3 box-orient 属性CSS 3 box-pack 属性CSS 3 box-shadow 属性CSS 3 box-sizing 属性CSS caption-side 属性CSS clear 属性CSS clip 属性CSS color 属性CSS 3 column-count 属性CSS 3 column-fill 属性CSS 3 column-gap 属性CSS 3 column-rule 属性CSS 3 column-rule-color 属性CSS 3 column-rule-style 属性CSS 3 column-rule-width 属性CSS 3 column-span 属性CSS 3 column-width 属性CSS 3 columns 属性CSS content 属性CSS counter-increment 属性CSS counter-reset 属性CSS cursor 属性CSS direction 属性CSS display 属性CSS empty-cells 属性CSS 3 filter(滤镜) 属性CSS flex 属性CSS flex-basis 属性CSS flex-direction 属性CSS flex-flow 属性CSS flex-grow 属性CSS flex-shrink 属性CSS flex-wrap 属性CSS float 属性CSS font 属性CSS 3 @font-face 规则CSS font-family 属性CSS font-size 属性CSS 3 font-size-adjust 属性CSS 3 font-stretch 属性CSS font-style 属性CSS font-variant 属性CSS font-weight 属性CSS 3 grid-columns 属性CSS 3 grid-rows 属性CSS 3 hanging-punctuation 属性CSS height 属性CSS 3 icon 属性CSS justify-content 属性CSS 3 @keyframes 规则CSS left 属性CSS letter-spacing 属性CSS line-height 属性CSS list-style 属性CSS list-style-image 属性CSS list-style-position 属性CSS list-style-type 属性CSS margin 属性CSS margin-bottom 属性CSS margin-left 属性CSS margin-right 属性CSS margin-top 属性CSS max-height 属性CSS max-width 属性CSS 3 @media 查询CSS min-height 属性CSS min-width 属性CSS 3 nav-down 属性CSS 3 nav-index 属性CSS 3 nav-left 属性CSS 3 nav-right 属性CSS 3 nav-up 属性CSS 3 opacity 属性CSS order 属性CSS outline 属性CSS outline-color 属性CSS 3 outline-offset 属性CSS outline-style 属性CSS outline-width 属性CSS overflow 属性CSS 3 overflow-x 属性CSS 3 overflow-y 属性CSS padding 属性CSS padding-bottom 属性CSS padding-left 属性CSS padding-right 属性CSS padding-top 属性CSS page-break-after 属性CSS page-break-before 属性CSS page-break-inside 属性CSS 3 perspective 属性CSS 3 perspective-origin 属性CSS position 属性CSS 3 punctuation-trim 属性CSS quotes 属性CSS 3 resize 属性CSS right 属性CSS 3 rotation 属性CSS3 rotation-point 属性CSS tab-size 属性CSS table-layout 属性CSS 3 target 属性CSS 3 target-name 属性CSS 3 target-new 属性CSS 3 target-position 属性CSS text-align 属性CSS text-align-last 属性CSS text-decoration 属性CSS text-decoration-color 属性CSS text-decoration-line 属性CSS text-decoration-style 属性CSS text-indent 属性CSS 3 text-justify 属性CSS 3 text-outline 属性CSS 3 text-overflow 属性CSS 3 text-shadow 属性CSS text-transform 属性CSS 3 text-wrap 属性CSS top 属性CSS 3 transform 属性CSS 3 transform-origin 属性CSS 3 transform-style 属性CSS 3 transition 属性CSS 3 transition-delay 属性CSS 3 transition-duration 属性CSS 3 transition-property 属性CSS 3 transition-timing-functionCSS unicode-bidi 属性CSS vertical-align 属性CSS visibility 属性CSS white-space 属性CSS width 属性CSS word-spacing 属性CSS 3 word-wrap 属性CSS z-index 属性CSS 3 text-emphasis 属性CSS 3 overflow-style 属性

CSS 函数

我一直以为 css 标准规范中是没有函数的,可没想到还真有几个

函数 描述 CSS 版本
attr() 返回选择元素的属性值 2
calc() 允许计算 CSS 的属性值,比如动态计算长度值 3
linear-gradient() 创建一个线性渐变的图像 3
radial-gradient() 用径向渐变创建图像 3
repeating-linear-gradient() 用重复的线性渐变创建图像 3
repeating-radial-gradient() 类似 radial-gradient(),用重复的径向渐变创建图像 3

CSS attr() 函数

CSS attr() 函数返回选择元素的属性值

attr(attribute-name)
描述
attribute-name必须。html 元素的属性名

范例

下面的代码在每个 <a> 标签后插入链接的 URL

a:after {
    content: " (" attr(href) ")";
}


CSS calc() 函数

CSS calc() 函数用于动态计算长度值

calc(expression)
描述
expression必须,一个数学表达式,结果将采用运算后的返回值
  1. 运算符前后都需要保留一个空格,例如:width: calc(100% - 10px)
  2. 任何长度值都可以使用 calc() 函数进行计算
  3. calc() 函数支持 "+", "-", "*", "/" 运算
  4. calc() 函数使用标准的数学运算优先级规则

范例

下面的代码使用 calc() 函数计算 <div> 元素的宽度

#div1 {
    position: absolute;
    left: 50px;
    width: calc(100% - 100px);
    border: 1px solid black;
    background-color: yellow;
    padding: 5px;
    text-align: center;
}


CSS linear-gradient() 函数

CSS3 函数 linear-gradient() 用于创建一个线性渐变的 "图像"

background: linear-gradient(direction, color-stop1, color-stop2, ...);
描述
direction用角度值指定渐变的方向(或角度)
color-stop1,
color-stop2,
...
用于指定渐变的起止颜色

线性渐变

为了创建一个线性渐变,需要设置一个起始点和一个方向(指定为一个角度)的渐变效果,同时还要定义终止色

终止色就是想让 Gecko 去平滑的过渡,并且必须指定至少两种,当然也会可以指定更多的颜色去创建更复杂的渐变效果

范例

下面的代码演示了从头部开始的线性渐变,从红色开始,转为黄色,再到蓝色

#grad {
    background: -webkit-linear-gradient(red,yellow,blue); /* Safari 5.1-6.0 */
    background: -o-linear-gradient(red,yellow,blue); /* Opera 11.1-12.0 */ 
    background: -moz-linear-gradient(red,yellow,blue); /* Firefox 3.6-15 */
    background: linear-gradient(red,yellow,blue); /* 标准语法 */
}

范例 2

下面的代码演示了从左侧开始的线性渐变,从红色开始,转为蓝色

#grad {
  background: -webkit-linear-gradient(left, red , blue); /* Safari 5.1 to 6.0 */
  background: -o-linear-gradient(right, red, blue); /* Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(right, red, blue); /* Firefox 3.6 to 15 */
  background: linear-gradient(to right, red , blue); /* 标准语法 */
}

范例 3

下面的代码演示了从左上角到右下角的线性渐变

#grad {
  background: -webkit-linear-gradient(left top, red , blue); /* Safari 5.1 to 6.0 */
  background: -o-linear-gradient(bottom right, red, blue); /* Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(bottom right, red, blue); /* Firefox 3.6 to 15 */
  background: linear-gradient(to bottom right, red , blue); /* 标准语法 */
}

范例 4

下面的代码演示了线性渐变指定一个角度

#grad {
  background: -webkit-linear-gradient(180deg, red, blue); /* Safari 5.1 to 6.0 */
  background: -o-linear-gradient(180deg, red, blue); /* Opera 11.1 to 12.0 */
  background: -moz-linear-gradient(180deg, red, blue); /* Firefox 3.6 to 15 */
  background: linear-gradient(180deg, red, blue); /* 标准语法 */
}

范例 5

下面的代码演示了多个终止色

#grad {
  /* For Safari 5.1 to 6.0 */
  background: -webkit-linear-gradient(left,red,orange,yellow,green,blue,indigo,violet);
  /* For Opera 11.1 to 12.0 */
  background: -o-linear-gradient(left,red,orange,yellow,green,blue,indigo,violet);
  /* For Fx 3.6 to 15 */
  background: -moz-linear-gradient(left,red,orange,yellow,green,blue,indigo,violet);
  /* 标准语法 */
  background: linear-gradient(to right, red,orange,yellow,green,blue,indigo,violet); 
}

范例 6

下面的代码使用了透明度

#grad {
  background: -webkit-linear-gradient(left,rgba(255,0,0,0),rgba(255,0,0,1)); /*Safari 5.1-6*/
  background: -o-linear-gradient(right,rgba(255,0,0,0),rgba(255,0,0,1)); /*Opera 11.1-12*/
  background: -moz-linear-gradient(right,rgba(255,0,0,0),rgba(255,0,0,1)); /*Fx 3.6-15*/
  background: linear-gradient(to right, rgba(255,0,0,0), rgba(255,0,0,1)); /*Standard*/
}


CSS radial-gradient() 函数

CSS 3 linear-gradient() 函数可以用来创建径向渐变

background: radial-gradient(shape size at position, start-color, ..., last-color);
描述
shape确定圆的类型:
ellipse (默认): 指定椭圆形的径向渐变
circle :指定圆形的径向渐变
size定义渐变的大小,可能值:
farthest-corner (默认) : 指定径向渐变的半径长度为从圆心到离圆心最远的角
closest-side :指定径向渐变的半径长度为从圆心到离圆心最近的边
closest-corner : 指定径向渐变的半径长度为从圆心到离圆心最近的角
farthest-side :指定径向渐变的半径长度为从圆心到离圆心最远的边
position定义渐变的位置。默认值为 center

可能的值有:
center (默认):设置中间为径向渐变圆心的纵坐标值
top:设置顶部为径向渐变圆心的纵坐标值
bottom:设置底部为径向渐变圆心的纵坐标值
start-color,
...,
last-color
用于指定渐变的起止颜色

CSS 3 repeating-linear-gradient() 函数

CSS 3 repeating-linear-gradient() 函数用于创建重复的线性渐变 "图像"

background: repeating-linear-gradient(angle | to side-or-corner, color-stop1, color-stop2, ...);
Value描述
angle定义渐变的角度方向。从 0deg 到 360deg,默认为 180deg
side-or-corner指定线性渐变的起始位置。由两个关键字组成:
第一个为指定水平位置(left 或 right)
第二个为指定垂直位置 ( top 或 bottom )
顺序是随意的,每个关键字都是可选的
color-stop1,
color-stop2,
...
指定渐变的起止颜色,由颜色值、停止位置(可选,使用百分比指定)组成




链接: https://www.fly63.com/course/6_261