背景图像区域 与 背景图像定位

background-clip 属性(IE9+,其他都兼容)

该属性指定了背景图像的绘制区域

语法:

background-clip: border-box|padding-box|content-box;

其中,border-box 为背景裁剪到边框盒(边框、内边距、内容都显示背景图片),padding-box为背景裁剪到内边距框(内边距、内容都显示背景图片),content-box为背景裁剪到内容框(仅内容显示背景图片)。

<!DOCTYPE html>
<html>
<head>
	<title>背景图像区域</title>
	<meta charset="utf-8">
	<style type="text/css">
		div{
			width: 800px;
			height: 400px;
			padding: 50px;
			border: 50px solid transparent;
			background: url('./imgs/lion.png') no-repeat center center;
			background-clip: border-box;
			background-clip: padding-box;
			background-clip: content-box;
		}
	</style>
</head>
<body>
	<div></div>

</body>
</html>

 

background-origin 属性(IE9+ Firefox4+ chrome safari5+ opera)

该属性设置元素背景图片的原始起始位置。其指定background-position属性对应的相对位置。

语法:

background-origin:padding-box|border-box|content-box;

通过以上三个值,分别规定了background-position的相对偏移的原点。

	<style type="text/css">
		div{
			width: 800px;
			height: 400px;
			padding: 50px;
			border: 50px solid transparent;
			background: url('./imgs/lion.png') no-repeat 50px 100px;
			background-origin: border-box;
			background-origin: padding-box;
			background-origin: content-box;
		}
	</style>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值