html5中怎样从一堆图标中选出想要的那一个(反向偏移)

原图:


用HTML处理后:

代码:

<!DOCTYPE html>
<html>
<head>
	<title>CSS</title>
	<meta charset="utf-8">
	<style type="text/css">
		
		div{
			background-image: url("../img/oauth.gif");
			background-position:-46px 10px;
			background-repeat: no-repeat;
			/* 必须加上width和height*/
			width: 45px;
			height: 55px;

	    	
		}
		
	</style>
	
</head>
<body>
	<div></div>
	<p>QQ号:123456</p>





</body>
</html>

background-position:-46px 10px;设置反向偏移,实现选取特定的图标,其中 -46px,10px,的单位px不能遗漏。这个数据可以通过截图工具界定一下。另外,电脑中的x,y轴是这样的:



猜你喜欢

转载自blog.csdn.net/it_zxl001/article/details/79820179
今日推荐