2.3.0 background(CSS)

2.3.0 background

这里是引用

可以使用background -image:url(); 可以替代标签
background-attachment:scroll为默认属性 图片根据父标签的位置而固定
:fixed 图片会根据父标签的位置而滚

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">

	#main{
		width: 1000px;
		height: 2000px;
		border: 1px solid black;
		background-color: yellow;
	}

	#one{
		width: 800px;
		height: 800px;
		background-image: url(./image/2.jpg);/* 可以使用background-image:url(地址); 可以替代<img>标签 */
		background-repeat: no-repeat;/*no-repeat图片不重复(默认属性为重复)   repeat:重复    repeat-x:x方向重复 repeat-y:y方向上重复 */
		background-position: 100px 100px;
		background-attachment: fixed;/* background-attachment:scroll为默认属性  图片根据父标签的位置而固定
		                                                     :fixed 图片会根据父标签的位置而滚   */
	}


	</style>
</head>
<body>
<div id="main">
	<div id="one">
		
	</div>
</div>
</body>
</html>

精灵效果

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style type="text/css">

	body{
		margin: 0;
		padding: 0;
	}

	body{
		margin: 100px;
	}

	a{
		display: block;
		width: 55px;
		height: 54px;
		background-image: url(./image/toolbar_cart.png);
	}

	a:hover{
		background-image: url(./image/toolbar_cart_focus.png);
		
	}


	</style>
</head>
<body>
	
	<a href="#"></a>
</body>
</html>

./image/toolbar_cart.png
在这里插入图片描述

./image/toolbar_cart_focus.png
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值