" />
开发者

css sprites: which html element using for background-position?

开发者 https://www.devze.com 2023-01-25 13:58 出处:网络
I am wondering for using css sprites which tag html is best? I mean i can use < img src=\"trasparent.png\" sty开发者_开发百科le=\"background-position:ecc\">

I am wondering for using css sprites which tag html is best?

I mean i can use

< img src="trasparent.png" sty开发者_开发百科le="background-position:ecc"> or ?

I saw Google using < span> for the "o" of G"o o o o o"gle

thanks


You can use almost any element you like.

One thing to note though is that elements like <span> and <a> are inline elements. Thus if you try and add dimensions to them to match the size of your background sprite, these dimensions will be ignored. To fix this you can use things like line-heights or padding to set dimensions, or you could change the element into a block level element using the CSS: display:block.

Another rule that will allow dimensions to be added is display:inline-block, but this can cause a few issues in IE6 and earlier browsers.


Google is actually using a span, in my experience is a good choice too.

0

精彩评论

暂无评论...
验证码 换一张
取 消