css a background,CSS background 属性详解

语法:

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

Note: If one of the properties in the shorthand declaration is the bg-size property, you must usea / (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

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;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值