<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.box1 {
width: 60px;
height: 60px;
margin: 100px auto;
background: url(images/sprites.png);
background-position: -182px 0;
}
.box2 {
width: 270px;
height: 25px;
background-color: pink;
margin: 200px;
background: url(images/sprites.png) no-repeat -155px -106px;
}
</style>
</head>
<body>
<div class="box1"></div>
<div class="box2"></div>
</body>
</html>
本文介绍了如何使用HTML和CSS实现背景图片精灵技术,通过`<div>`元素和CSS样式,展示了如何控制不同大小的元素使用同一张包含多个图像的sprites.png文件作为背景。
845

被折叠的 条评论
为什么被折叠?



