我在我的网站中使用4个独立的图像,现在如果我使用图像精灵来显示这4个图像,它会减少http请求,如果是这样,我想知道。CSS图像精灵
考虑下面实例1:(这里是2 HTTP请求发送)
<!DOCTYPE html>
<html>
<head>
<style>
#home {
width: 46px;
height: 44px;
background: url(sevenwonders.gif) 0 0;//first http request
}
#next {
width: 43px;
height: 44px;
background: url(sevenwonders.gif) -91px 0; //second http request
}
</style>
</head>
<body>
<img id="home" src="something.gif">
<img id="next" src="something.gif">
</body>
</html>
考虑例如2以下(2个HTTP请求发送)
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<img id="home" src="tajmahal.gif">//first http request
<img id="next" src="pisatower.gif">//second http request
</body>
</html>
谢谢你这么多宝贵的时间。
你的问题到底是什么?在第一个示例中,您只有一个HTTP请求,因为它只有一个图像,但使用了两次背景偏移量。 –
谢谢你@ johnny kutnowski .anyhow我做了两个http请求的单个图像。这是我的疑问 –
可以请你详细解答@johnny kutnowski –