CSS背景

2017-12-12  本文已影响0人  白小九

一、背景色与绘制区域

背景色
background-color: <color> | transparent;
裁剪/背景绘制区域
background-clip: <box>;
/* <box> = content-box | padding-box | border-box; */
属性简写
background: [ <bg-layer> , ]* <final-bg-layer>;
/* <bg-layer> = <bg-img> || <pos> [/ <bg-size>]? || <repeat> || <attach> || <box>{1,2};
  <final-bg-layer> = <bg-layer> || <color>;
 */

二、背景图

设置背景图片
background-image: [ <bg-img> | none ]#;
/* <bg-img> = url(<path>) | <gradient> */
背景图片的定位区域
background-origin: <box>#;
/* <box> = content-box | padding-box | border-box; */
背景图片的尺寸
background-size: <bg-size>#;
/* <bg-size> = [ <width> <height>? ] | cover | contain; */
背景图片的起始位置
background-position: <pos>#;
/* <pos> = <pos1> | <pos2> | <pos3>;
  <pos1> = left | center | right | top | bottom | <len-%>;
  <pos2> = [ left | center | right | <len-%> ][ top | center | bottom | <len-%> ];
  <pos3> = [ center | [ left | right ] <len-%>? ] && [ center | [ top | bottom ] <len-%>? ];
  <len-%> = <length> | <%>;
 */
背景图片重复
background-repeat: <repeat>;
/* <repeat> = repeat | repeat-x | repeat-y | no-repeat | space | round; */
背景图片关联
background-attachment: <attach>;
/* <attach> = scroll | local | fixed; */

三、渐变

线性渐变
linear-gradient([ <angle> | to <side-or-corner>, ]? <color-stop>#{2,})
/* <side-or-corner> = [ left | right ] || [ top | bottom ];
  <color-stop> = <color> <len-%>?;
 */
径向渐变(中心辐射)
radial-gradient([ <shape> || <size> ][ at <pos> ]? , <color-stop>#{2,})
/* <shape>  =  circle || ellipse;
  <size> = <ex-keyword> | <length> | <len-%>{2};
  <ex-keyword> = closest-side | farthest-side | closest-corner | farthest-corner;
  <color-stop> = <color> <len-%>?;
 */
渐变重复
repeating-linear-gradient()
repeating-radial-gradient()
上一篇 下一篇

猜你喜欢

热点阅读