CSS background Property

语法:

background: bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;

Note: If one of the properties in the shorthand declaration is the bg-size property, you must use a / (slash) to separate it from the bg-position property, e.g. background:url(smiley.gif) 10px 20px/50px 50px; will result in a background image, positioned 10 pixels from the left, 20 pixels from the top, and the size of the image will be 50 pixels wide and 50 pixels high.

Note: If using multiple background-image sources but also want a background-color, the background-color parameter needs to be last in the list.

background-color

background-color

Default value: transparent

The background-color property sets the background color of an element.

The background of an element is the total size of the element, including padding and border (but not the margin)(包括内边距和边框).

background-position

The background-position property sets the starting position of a background image(背景图片的开始位置).

Tip: By default, a background-image is placed at the top-left corner of an element, and repeated both vertically and horizontally.

background-size

The background-size property specifies the size of the background images.

语法:

background-size: auto|length|cover|contain|initial|inherit;

background-repeat

The background-repeat property sets if/how(背景图片的重复/循环方式) a background image will be repeated.

By default, a background-image is repeated both vertically and horizontally.

Tip: The background image is placed according to the background-position property. If no background-position is specified, the image is always placed at the element's top left corner.

background-repeat: repeat|repeat-x|repeat-y|no-repeat|initial|inherit;

background-origin

Default value: padding-box

The background-origin property specifies where the background image is positioned.

Note: If the background-attachment property is set to "fixed", this property has no effect.

background-origin: padding-box|border-box|content-box|initial|inherit;

background-clip

The background-clip property specifies the painting area of the background.

background-clip: border-box|padding-box|content-box|initial|inherit;

background-attachment

The background-attachment property sets whether a background image is fixed or scrolls with the rest of the page.

background-attachment: scroll|fixed|local|initial|inherit;

最新文章

  1. 在 CSS 预编译器之后:PostCSS
  2. 【字符串匹配】KMP算法和next数组的c/c++实现
  3. Linux下安装VMware Tools 的方法
  4. Linux学习之路—Linux文件权限
  5. cf#306D. Regular Bridge(图论,构图)
  6. OJ上 G++ 与 C++ 的区别
  7. Codeforces Round #292 (Div. 1) C. Drazil and Park 线段树
  8. 本地与在线图片转Base64及图片预览
  9. 查看iOS视图层级并修改UIsearchBar的cancel按钮不失去作用
  10. git提交
  11. 杜教筛 && bzoj3944 Sum
  12. bzoj 2946
  13. Springcloud Gateway 路由管理
  14. jQuery.Ajax IE8,9 无效(CORS跨域)
  15. CodeForces 931C Laboratory Work 水题,构造
  16. crawler_exa3
  17. CentOS 7 系统优化
  18. ClickHouse之简单性能测试
  19. 【github&&git】4、git常用命令(持续更新中)
  20. Go语言中Socket通信之Tcp客户端

热门文章

  1. 插播一条 QQ头像无法正常显示问题
  2. 【old】Python学习笔记
  3. 8. JavaScript学习笔记——事件
  4. [问题解决]Fresco设置占位图不显示的问题
  5. python-fork聊天室
  6. C 标准库 - string.h之memmove使用
  7. 多线程编程(三)-CountDownLatch的使用
  8. spring data 自定义接口
  9. Android Studio 和 gradle 修改缓存文件夹路径
  10. 将一个表的数据导入到另一个表的sql