css精灵图技术是什么

248次阅读
没有评论

css精灵图技术是什么

1、将页面所涉及的所有零星背景图像集中到大图中,然后将大图用于网页。用户访问页面时,只需向服务器发送一次请求。

2、直接使用background-position等属性来准确定位所需的背景部分。

实例

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
    <div>
        <span></span>
        <span></span>
        <span></span>
    </div>
</body>
<style>
    .box span {
        display: inline-block;
    }
    .j {
        background: url("abcd.jpg") no-repeat -389px -141px;
        width: 102px;
        height: 112px;
    }
    .w {
        background: url("abcd.jpg") no-repeat -117px -560px;
        width: 135px;
        height: 112px;
    }
    .t {
        background: url("abcd.jpg") no-repeat -368px -417px;
        width: 102px;
        height: 112px;
    }
</style>
</html>

以上就是css精灵图技术的介绍,希望对大家有所帮助。更多css学习指路:css教程

神龙|纯净稳定代理IP免费测试>>>>>>>>天启|企业级代理IP免费测试>>>>>>>>IPIPGO|全球住宅代理IP免费测试

相关文章:

版权声明:JavaScript2022-12-19发表,共计738字。
新手QQ群:570568346,欢迎进群讨论 Python51学习