1.css背景-用于定义HTML元素的背景
-
background-color:背景颜色
-
background-color:yellow; background-color:#00ff00; background-color:rgb(255,0,255);
值 描述 color 指定背景颜色。在CSS颜色值近可能的寻找一个颜色值的完整列表。 transparent 指定背景颜色应该是透明的。这是默认 inherit 指定背景颜色,应该从父元素继承
-
-
background-images:背景图像
-
background-image:url('paper.gif'); //可以给不同的图片设置多个不同的属性 #example1 { background-image: url(img_flwr.gif), url(paper.gif); background-position: right bottom, left top; background-repeat: no-repeat, repeat; }
值 说明 url('URL') 图像的URL none 无图像背景会显示。这是默认 linear-gradient() 创建一个线性渐变的 "图像"(从上到下) radial-gradient() 用径向渐变创建 "图像"。 (center to edges) repeating-linear-gradient() 创建重复的线性渐变 "图像"。 repeating-radial-gradient() 创建重复的径向渐变 "图像" inherit 指定背景图像应该从父元素继承
-
-
background-origin:内容框相对定位的背景图片
-
background-origin: padding-box|border-box|content-box;
值 描述 padding-box 背景图像填充框的相对位置 border-box 背景图像边界框的相对位置 content-box 背景图像的相对位置的内容框
-
-
background-position:设置背景图像的起始位置
-
background-position:center; //可以给不同的图片设置多个不同的属性 #example1 { background-image: url(img_flwr.gif), url(paper.gif); background-position: right bottom, left top; background-repeat: no-repeat, repeat; }
值 描述 left top
left center
left bottom
right top
right center
right bottom
center top
center center
center bottom如果仅指定一个关键字,其他值将会是"center" x% y% 第一个值是水平位置,第二个值是垂直。左上角是0%0%。右下角是100%100%。如果仅指定了一个值,其他值将是50%。 。默认值为:0%0% xpos ypos 第一个值是水平位置,第二个值是垂直。左上角是0。单位可以是像素(0px0px)或任何其他 CSS单位。如果仅指定了一个值,其他值将是50%。你可以混合使用%和positions inherit 指定background-position属性设置应该从父元素继承
-
-
background-repeat:背景图像 - 水平或垂直平铺
-
background-repeat:repeat; //可以给不同的图片设置多个不同的属性 #example1 { background-image: url(img_flwr.gif), url(paper.gif); background-position: right bottom, left top; background-repeat: no-repeat, repeat; }
值 说明 repeat 背景图像将向垂直和水平方向重复。这是默认 repeat-x 只有水平位置会重复背景图像 repeat-y 只有垂直位置会重复背景图像 no-repeat background-image不会重复 inherit 指定background-repea属性设置应该从父元素继承
-
-
background-size:指定背景图像的大小
-
background-size:80px 60px;
值 描述 length 设置背景图片高度和宽度。第一个值设置宽度,第二个值设置的高度。如果只给出一个值,第二个是设置为 auto(自动) percentage 将计算相对于背景定位区域的百分比。第一个值设置宽度,第二个值设置的高度。如果只给出一个值,第二个是设置为"auto(自动)" cover 此时会保持图像的纵横比并将图像缩放成将完全覆盖背景定位区域的最小大小。 contain 此时会保持图像的纵横比并将图像缩放成将适合背景定位区域的最大大小。
-
-
background-clip:指定绘图区的背景(css3)
-
background-clip: border-box|padding-box|content-box;
值 说明 border-box 默认值。背景绘制在边框方框内(剪切成边框方框)。 padding-box 背景绘制在衬距方框内(剪切成衬距方框)。 content-box 背景绘制在内容方框内(剪切成内容方框)。
-
-
background:简写属性
-
background:bg-color bg-image position/bg-size bg-repeat bg-origin bg-clip bg-attachment initial|inherit;
值 说明 CSS background-color 指定要使用的背景颜色 1 background-position 指定背景图像的位置 1 background-size 指定背景图片的大小 3 background-repeat 指定如何重复背景图像 1 background-origin 指定背景图像的定位区域 3 background-clip 指定背景图像的绘画区域 3 background-attachment 设置背景图像是否固定或者随着页面的其余部分滚动。 1 background-image 指定要使用的一个或多个背景图像 1
-