01_04.background属性

本文深入探讨CSS背景属性的使用方法,包括默认背景、水平重复、垂直重复、不重复等样式,以及背景位置的精确控制。通过实例展示如何灵活运用这些属性实现网页布局与美化。
<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="content-type" content="text/html;charset=utf-8">
		<link rel="stylesheet" type="text/css" href="style/01_05_background.css">
	</head>
	<body id="bg">
		1.默认背景
		<div id="moren"></div>
		2.默认背景水平重复
		<div id="chongfu_shuiping"></div>
		3.默认背景垂直重复
		<div id="chongfu_chuizhi"></div>
		4.默认背景不重复
		<div id="chongfu_buchongfu"></div>
		<hr />
		<p>(tip:如果水平、垂直任意一项规定了值,另一项为居中)</p>
		<hr />
		5.默认背景水平方向居左,垂直居下
		<div id="weizhi_shuiping_zuo_chuizhi_xia"></div>
		6.默认背景垂直方向居上,水平居右
		<div id="weizhi_chuizhi_shang_shuiping_you"></div>
		7.缩写
		<div id="suoxie"></div>
	</body>
</html>
#bg{

	background: url(../images/01_05_background_body.jpg) top no-repeat #B0D76C fixed;
}
#moren{
	width: 200px;
	height:200px;
	background-color:green;
	background-image: url(../images/01_05_background.png);
}
#chongfu_shuiping{
	width: 200px;
	height:200px;
	background-color:green;
	background-image: url(../images/01_05_background.png);
	background-repeat: repeat-x;
}
#chongfu_chuizhi{
	width: 200px;
	height:200px;
	background-color:green;
	background-image: url(../images/01_05_background.png);
	background-repeat: repeat-y;
}
#chongfu_buchongfu{
	width: 200px;
	height:200px;
	background-color:green;
	background-image: url(../images/01_05_background.png);
	background-repeat: no-repeat;
}
#weizhi_shuiping_zuo_chuizhi_xia{
	width: 200px;
	height:200px;
	background-color:green;
	background-image: url(../images/01_05_background.png);
	background-repeat: no-repeat;
	background-position: left bottom;	

}
#weizhi_chuizhi_shang_shuiping_you{
	width: 200px;
	height:200px;
	background-color:green;
	background-image: url(../images/01_05_background.png);
	background-repeat: no-repeat;
	background-position:  top right;
}
#suoxie{
	width: 200px;
	height:200px;
	background: red url(../images/01_05_background.png) no-repeat center;
}


评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值