gpt4 book ai didi

css - 为什么某些网站(例如 youtube)上的图标都保存在同一个文件中?

转载 作者:行者123 更新时间:2023-11-28 04:51:45 26 4
gpt4 key购买 nike

我试图将 youtube 的布局复制为 css 练习,在尝试下载图标时我发现它们都保存在一个文件中。我试图附上一张图片,但我没有足够的声誉。请点击链接了解我的意思。

我想这样做是为了以某种方式节省带宽,可能(如果我错了请纠正我)限制每个客户端对服务器的请求数量?

这些图标中的每一个是如何与其他图标分开加载的?什么时候采用这种方法比让每个图标对应一个文件更有利?

single image file containing all the icons of youtube.com

最佳答案

您可以使用 background-position 来做到这一点CSS 属性。 w3schools.com 上解释了为什么要使用 sprite 表:

A web page with many images can take a long time to load and generates multiple server requests.

Using image sprites will reduce the number of server requests and save bandwidth.

关于css - 为什么某些网站(例如 youtube)上的图标都保存在同一个文件中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40662668/

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