css背景

<!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>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值