<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>css背景图</title>
<style type="text/css">
#first {
width: auto;
height: 2000px;
border: solid;
background-image: url(img/logo.JPG);
background-repeat: no-repeat;
background-position: 100px 0px;
background-attachment: scroll
}
</style>
</head>
<!--
描述:背景
使用颜色:
background-color:颜色值
使用图片
background-image: url(图片路径); 设置图片路径
background-repeat: no-repeat/repeat-x/repeat-y 设置是否重复
background-position: 设置显示位置
1.top / right / center /left /bottom
2.百分数值
left - right : 0% ~ 100 %
top - bottom : 0% ~ 100%
50% 50% 居中
background-position: 50% 50%;
3.px
指定x y 偏移量
background-position: 100px 0px;
background-attachment: fixed 背景位置固定在窗口上
background-attachment: scroll 背景会跟着滑动划出(默认)
-->
<body>
<div id="first">
第一个div
</div>
</body>
</html>