css背景background

background用来定义html元素的背景效果

background-color:定义元素的背景颜色,背景的颜色值通常有三种定义方法

1.十六进制方式,如"#ff0000"

2.RGB方式,如"rgb(255,0,0)"

3.颜色名称,如"red"

background-image:定义元素的背景图片,通过background-image:url(‘path/图片名称‘)指定

默认情况下,背景图片会在水平和垂直方向上进行平铺重复显示,即默认的background-repeat值为repeat

background-repeat:定义元素的背景图片是否以及如何重复显示

默认值值repeat,no-repeat、repeat-x、repeat-y分别表示不重复、在水平方向、垂直方向重复显示

background-attachment:定义元素的背景图片是否固定或者随着页面的其余部分滚动

默认值为scroll随页面部分滚动,fixed表示固定不滚动,inherit表示从父元素继承

background-position:定义元素的背景图片起始位置,例如定义图片右上角不重复显示

(left center right * top center bottom)九种组合,并且这两个值如果只指定一个那么另外一个默认为center

x% y%:表示水平位置和垂直位置,默认为左上角0% 0%,右下角是100% 100%,

xpos ypos:表示水平位置和垂直位置

inherit表示从父元素继承

背景效果通过上述5个属性来控制,为使用方便可以将这些属性合并在一起,简写为 "background",当时用简写属性时,顺序为color、image、repeat、attachment、position,可根据实际需要选择,无需全部使用,例如

body {background:lightpink url(‘img_tree.png‘) no-repeat right top;}

原文地址:https://www.cnblogs.com/Forever77/p/10203911.html

时间: 2024-07-31 07:39:47

css背景background的相关文章

CSS背景background、background-position使用详解

背景(background)是css中一个重要的的部分,也是需要知道的css的基础知识之一.这篇文章将会涉及css背景(background)的基本用法,包括诸如 background-attachment 等的属性,也会介绍一些有关背景(background)的常用技巧,以及 css3 中的 背景(background)(包含4个新的背景(background)属性). css2 中的背景(background) 概述 CSS2 中有5个主要的背景(background)属性,它们是: * p

CSS 背景background实例

css背景background用于设置html标签元素的背景颜色.背景图片已经其他背景属性.本文章向码农介绍CSS 背景background使用方法和基本的使用实例.需要的码农可以参考一下. 一.Css background背景语法 CSS背景基础知识 CSS 背景这里指通过CSS对对象设置背景属性,如通过CSS设置背景各种样式. 背景语法: background: background-color || background-image || background-repeat || back

关于CSS背景background属性经典的配置

background background-color: transparent; background-image: url("/assets/images/phonetitle1.gif"); background-repeat: repeat; background-attachment: scroll; background-position: 0% 0%; background-clip: border-box; background-origin: padding-box;

web前端入门到实战:CSS背景background

1.背景颜色 background-color 取值:合法的颜色值和transparent 注:背景颜色和背景图片,填充都是从边框开始 2.背景图片 background-image:url(图片路径) 3.背景图平铺 background-repeat: 取值: repeat:平铺 no-repeat:不平铺 repeat-x:水平方向平铺 repeat-y:垂直方向平铺 4.背景图定位 background-posion:x y,设定的值都是相对于浏览器,不是相对于容器 取值: (1):x,

DIV CSS Sprites精灵 CSS图像拼合 CSS背景贴图定位教程案例

div css sprites精灵-CSS图像拼合 CSS贴图定位网页背景素材图片拼合定位布局技术教程篇与css sprites实例篇 css sprites拼合背景图片素材实现布局效果截图 一.什么是css sprites   -   TOP css sprites直译过来就是CSS精灵.通常被解释为“CSS图像拼合”或“CSS贴图定位”.其实就是通过将多个图片融合到一张图里面,然后通过CSS background背景定位技术技巧布局网页背景.这样做的好处也是显而易见的,因为图片多的话,会增加

css背景及css列表

CSS背景 background是一个综合属性,它分为以下几个属性. background-color 背景色 background-image 背景图片 background-repeat 设置背景图的平铺方式 属性值:no-repeat repeat-x repeat-y background-position 设置或检索对象的背景图像位置 background-size 设置背景图的尺寸 background-attachment 设置或检索背景图像是随对象内容滚动还是固定的 fixed 

CSS 背景-CSS background

这里有个很好的样式学习网站:http://www.divcss5.com/rumen/r125.shtml 一.Css background背景语法   -   TOP CSS背景基础知识 CSS 背景这里指通过CSS对对象设置背景属性,如通过CSS设置背景各种样式. 背景语法: background: background-color || background-image || background-repeat || background-attachment || background-

css之背景(background)家族

背景(background)是css中很重要的一部分,也是css的基础知道之一,现在来回顾css2中5个属性与css3中新增的3个属性和2个功能. CSS2_背景(background)前传 家族成员 背景(background)家族在css2中由5个主要的背景属性组成,分别是: background-color 指定填充的背景颜色 background-image 引用图片作为背景图 background-position 指定元素背景图片的位置 background-repeat 决定背景图

css中background背景属性概

css中background背景属性概 background:url(背景图片路径)  no-repeat;/*不重复默认在左上方*/ background:url(背景图片路径)  no-repeat center;/*不重复背景图片中间显示*/ background:url(背景图片路径)  no-repeat bottom center;/*不重复背景图片底部中间显示*/ background:url(背景图片路径)  no-repeat right top;/*不重复背景图片右上方显示*