DIV+CSS背景一张整图(css sprites)
以前看到很多大型网站,整个网站的背景图片,是同一张图片,下载他的背景图片,看到一张图片上有很多小图标。
也就是国外很流行的css sprites,目前国内也有很多网站这样用。
这次在写CSS+DIV时,也这样写了个整站,感觉虽然做网站的整站慢,但在网站的占用资源上,的确省了不少。
原理,一般网站的图片都是分开的,每个图片的调用都会占用一个IIS链接,而现在把所有图片放在一张图上时,所有图片都是一个图片,只要调用一次图片,就可以提供整个网页的图片用,这样只占一个IIS链接。
在制作过程用,就是把所有的图片,都用背景来实现,比如一个小图标,就用这显示,把exp的样式设置一个背景,背景就是一个图片。
如:
.exp { background-image: url(bg.gif);/*背景图片*/ background-repeat: no-repeat;/*不平铺*/ background-position: -300px -50px;/*设置背景图片在整个图的位置,在前面加个负号*/ width=25px;/*宽度*/ height=25px;/*高度*/ }
看到上面的吧,在设置背景时,会指定背景在图片上的位置,然后控制宽度和高度的大小,这样就显示了一个图标了,同样的方法,把网站所有的界面图片都以这样的方法显示,每个图上都是取大图中的一小部分。
每个小图标在大图片中的位置,可以在PS里用线查看。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to implement the table function of custom click to add data in dcatadmin (laravel-admin) When using dcat...

This article lists the top ten leading cryptocurrency exchanges in the world, including OKX, Binance, Gate.io, Huobi, Kraken, Coinbase, KuCoin, Crypto.com, Bitfinex and Bitstamp. With their strong technical strength, rich product lines, strict compliance operations and innovative ecological construction, these exchanges have taken the lead in the global cryptocurrency market. The article will introduce their special functions, technical architecture, security measures, compliance qualifications and ecosystem construction respectively, providing reference for investors to choose a suitable trading platform.

With the development of the cryptocurrency market, formal virtual currency trading software has become the focus of investors' attention. In the fierce competition, some trading platforms stand out and provide safe and reliable services. According to industry research and comprehensive rankings, this article will list the top ten best virtual currency trading software in the world in 2025 and provide its official website address. These platforms have been strictly reviewed and are designed to provide users with excellent trading experience and investment guarantees.

Dynamic web element crawling problem: dealing with XPath and Class name changes, many crawler developers will encounter a difficult problem when crawling dynamic web pages: the goal...

How to share the same page on the PC and mobile side and handle cache issues? In the nginx php mysql environment built using the Baota background, how to make the PC side and...

Confusion and the cause of choosing from PHP to Go Recently, I accidentally learned about the salary of colleagues in other positions such as Android and Embedded C in the company, and found that they are more...

The top ten cryptocurrency exchange app rankings in 2025 are: Binance, Coinbase, OKX, Huobi Global, KuCoin, Kraken, Gate.io, Bitfinex, Poloniex and Bitstamp. They stand out with their low trading fees, wide range of crypto assets, advanced trading tools, focus on compliance, and user-friendly interfaces.

The specific method of Nginx configuration only allows access to index.php. When using Nginx as a web server, sometimes we need to strictly control access, compared to...
