问题是如何定位从图像 Sprite 获得的图像,因为背景位置属性已经用于从 Sprite 定位图像?例如,在下面的代码中,我如何才能在网页中的所需位置定位从 Sprite 获得的家。
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<style type="text/css">
img.home
{
width:46px;
height:44px;
background:url(img_navsprites.gif) 0 0;
}
</style>
</head>
<body>
<img class="home" src="img_trans.gif" width="1" height="1" />
</body>
</html>
其中,(img_trans.gif) 是透明图像,(img_navsprites.gif) 是图像 Sprite 。
最佳答案
您应该通过设置 position: absolute
并设置 top
和 left
来移动整个元素。
关于html - 我们如何定位从图像 Sprite 获得的图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6721818/