background的属性(Background属性)

http://www.itjxue.com  2023-01-24 17:16  来源:未知  点击次数: 

css中background简写属性

在CSS2.1里,background属性的简写方式包含五种属性值,从CSS3开始,又增加了3个新的属性值,加起来一共8个。

CSS2.1

background-color使用的背景颜色。

background-image使用的背景图像。

background-repeat如何重复背景图像。

background-attachment背景图像是否固定或者随着页面的其余部分滚动。

background-position背景图像的位置。

CSS3

background-size背景图片的尺寸。默认值:'auto'? 其他值:像素,百分比,contain,cover

background-origin背景图片的定位区域。 默认值:'padding-box'? ? ? ? ?'border-box' 、'content-box'(定义背景图片绘制的开始点)

background-clip背景的绘制区域。 默认值:'border-box'? ? ? 还有'padding-box'、'content-box'(定义背景绘制的开始点)

简写方式:

background:background-color background-image background-repeat background-attachment background-position / background-size background-origin background-clip

不设置的属性可以省略

background-Origin属性指定background-position属性应该是相对位置。

注意

1、如果背景图像background-attachment是"固定",background-origin属性没有任何效果。

2、background-origin 和background-clip很容易混淆,前者是对背景图片而言,后者是对背景而言。不是一个概念。clip默认值比origin默认值范围大,所以默认不会有裁剪效果,如果想设置裁剪,可以把origin范围设置的比clip大就好。比如:origin:'border-box',clip:'padding-box'或者'content-box'.

3、background-size中contain和cover的区别。

cover此时会保持图像的纵横比并将图像缩放成将完全覆盖背景定位区域的最小大小。完全覆盖,可能有图片显示不完整的情况。

contain此时会保持图像的纵横比并将图像缩放成将适合背景定位区域的最大大小。可能有空白区域

如下图一设置的contain,图二设置的cover

background有哪些属性?

background-attachment:scroll | fixed scroll:背景图像是随对象内容滚动。 fixed:背景图像固定。background-color:transparent | color transparent:背景透明色。 color:指定颜色、background-image:none | url none:无背景图。 url:使用绝对或相对地址指定背景图像。background-position : length || length length : 百分数 | 由浮点数字和单位标识符组成的长度值。

background-position : position || position position : top | center | bottom | left | center | right

background-positionX : length | left | center | right length : 百分数 | 由浮点数字和单位标识符 组成的长度值。 left : 居左 ,center : 居中 ,right : 居右

background-positionY : length | top | center | bottom length : 百分数 | 由浮点数字和单位标识符组成的长度值。left : 居左 ,center : 居中 ,right : 居右

background-repeat : repeat | no-repeat | repeat-x | repeat-y repeat : 背景图像在纵向和横向上平铺,no-repeat : 背景图像不平铺,repeat-x : 背景图像在横向上平铺,repeat-y : 背景图像在纵向平铺

background是什么意思

1、background的基本意思是“背景”“底色”,主要指图画或照片中在主要人物或景象之后起衬托作用的部分。引申可表示“人的背景资料”,主要包括家庭、所属社会阶层、经历、学历状况等。还可表示“背景情况”,指事情发生时所处的时间、地点和外部环境等。

2、background主要用作可数名词。作“后景;背景”“底色”解时常用作单数名词;作“(事态发展等的)背景”解时常用作单数名词,也可用作不可数名词;作“不显眼的位置;幕后 ”解时只用作单数名词。

3、background后接介词for,of或to表示“某方面的背景或经历”; 接介词in 表示“在…背景中;在幕后”;前面加介词against表示“映衬在…背景上”。

4、“tell me your?background”现较流行,等同于“tell me all about yourself”。

扩展资料:

近义词

1、backdrop 

读音:英 ['b?kdr?p] 美 ['b?kdrɑ?p]    

n. 背景幕;背景

The events of the 1930s provided the backdrop for the film.

二十世纪三十年代的一些事件为这部电影提供了背景。

2、context 

读音:英 ['k?ntekst]? 美 ['k?ntekst]    

n. 上下文;环境;背景

This speech needs to be set in the context of Britain in the 1960s.

这篇演说需要放到20世纪60年代的英国这一背景之下来看待。

(责任编辑:IT教学网)

更多

推荐计算机等级考试文章