gpt4 book ai didi

CSS Sprite 整页背景 : background-position

转载 作者:太空宇宙 更新时间:2023-11-03 19:34:59 25 4
gpt4 key购买 nike

我有一张图片,我想将其顶部的 80 像素用于其他目的,其余图片,我想设置为整页背景图片。

我试过设置:

background-position: 0px -80px

但它不起作用。

如何正确使用css sprite(背景位置)和整页背景图?

最佳答案

其中任何一个(linklink)都会为您生成一个 sprite 和相应的 css。

完成后,使用相应区域的 css 类,例如:

.image1Background {
background-image: url("thesprite.png"),
left: -80px;
top: 0px;
}

.image2Background {
background-image: url("thesprite.png"),
left: 0px;
top: 0px;
}

<body class="image1Background">
<div class="image2Background">
</div>
</body>

Sprites 通常用于很多小图标,以减少将它们下载到客户端所需的请求数。

关于CSS Sprite 整页背景 : background-position,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9110509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com