您的位置:首页 > Web前端 > CSS

<css 一>background

2016-04-09 12:14 411 查看
内容概要:

background:
简写,设置背景属性。
background-color:
设置元素的背景颜色。
background-image:
设置为背景的图像
background-attachment:
背景图像是否固定或者随着页面的其余部分滚动。
background-position:
图像的起始位置
background-repeat:
是否以及如何重复
background-attachment :
背景图像固定或滚动
background-attachment:scroll
默认值。背景图像会随着页面其余部分的滚动而移动。
background-attachment:fixed
当页面的其余部分滚动时,背景图像不会移动。
提示:

需要把 background-attachment 属性设置为 "fixed",才能保证该属性在 Firefox 和 Opera 中正常工作。
例子:

<html>
<head>

<style type="text/css">
body {
background-image:url(1.png);
background-attachment:scroll;
}
</style>
</head>

<body>
这是内容.
注意:内容越多越好,以便于浏览器右侧有移动条,可以活动,这样的效果更明显。
</body>
</html>
background-position:(背景图像的初始位置)

此属性有三种写法:
background-position:100px 500px
background-position:100% 50%
background-position:center top
background-repeat:(背景图像是否重复以及如何重复)

此属性有以下几个值:
repeat
默认。背景图像将在垂直方向和水平方向重复。
repeat-x
背景图像将在水平方向重复。
repeat-y
背景图像将在垂直方向重复。
no-repeat
背景图像将仅显示一次。
例子:

<html>
<head>
<style type="text/css">
body{
background-image:url(1.png);
background-repeat:repeat-y;
}
</style>
</head>

<body>
背景图像。
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: