camelCase
The Case of the Mysterious Camel.
- Reaction score
- 362
I've always used one sprite per HTML element.
I was wondering if it were possible to have more than one HTML element share the same sprite.
Like,
<div id="something"></div>
<div id="somethingElse"></div>
<div id="somethingElseEntirely"></div>
The three (possibly more) divs would like to share the same sprite sheet.
How would I do that?
I usually do this:
But it will load 'someImage.png' three times from the server, right?
I just want to load it once and have that one sprite be used for all the divs.
I was wondering if it were possible to have more than one HTML element share the same sprite.
Like,
<div id="something"></div>
<div id="somethingElse"></div>
<div id="somethingElseEntirely"></div>
The three (possibly more) divs would like to share the same sprite sheet.
How would I do that?
I usually do this:
Code:
#something {
width: 400px;
height: 100px;
overflow: hidden;
background-image: url('someImage.png');
background-position: 0px 0px;
}
#somethingElse {
width: 400px;
height: 100px;
overflow: hidden;
background-image: url('someImage.png');
background-position: 400px 0px;
}
#somethingElseEntirely {
width: 400px;
height: 100px;
overflow: hidden;
background-image: url('someImage.png');
background-position: 800px 0px;
}
But it will load 'someImage.png' three times from the server, right?
I just want to load it once and have that one sprite be used for all the divs.