CSS 设置背景颜色、背景图片

我来纠错
CSS 背景属性用于定义HTML元素的背景。
CSS 属性定义背景效果:
background-color
background-image
background-repeat
background-attachment
background-position

//背景颜色
background-color 属性定义了元素的背景颜色.
body {background-color:#b0c4de;}
CSS中,颜色值通常以以下方式定义:
十六进制 - 如:"#ff0000"
RGB - 如:"rgb(255,0,0)"
颜色名称 - 如:"red"

//背景图像
background-image 属性描述了元素的背景图像.
默认情况下,背景图像进行平铺重复显示,以覆盖整个元素实体.
body {background-image:url('bgdesert.jpg');}

//背景图像 - 水平或垂直平铺
background-repeat 定义背景图片平铺方式:repeat-x、repeat-y,禁止平铺:no-repeat;
body{
background-image:url('gradient2.png');
background-repeat:repeat-x;
}

//背景图像 - 图片定位
background-position 属性改变图像在背景中的位置
body{ background-position:right top;}
body{ background-position:-10px -50px;}

//背景- 简写属性
body {background:#ffffff url('img_tree.png') no-repeat right top;}
发送
热门关键词:
命令
知识类型:
标题描述:
详细解答:

提交审核您编辑的知识会经过 前端大牛 人工审核。