How to position an image sprite at the bottom of an element of unknown height

自闭症网瘾萝莉.ら 提交于 2019-12-12 00:34:04

问题


I am using an image sprite that consisting of four "sub-images": four corners for a div element. The sprite is 40px by 40px. Each "sub-image" is 20px by 20px. Each corner's "sub-image is on the opposite corner of the sprite of where it would be on the dev element. For example, the top-left sub-image is at the bottom-right of the sprite.

This div element is 440px wide and 100% tall. I've got the top corners down but how do I get the bottom corners? Is there a way to do this without creating a new sprite? Here is what I've got so far for my CSS rule.

background: -20px -20px no-repeat url(<path>), 420px -20px no-repeat url(<path>);

回答1:


Put background-images on absolutely positioned pseudo-elements.

Demo

Sorry, misread your question, here is the same technique with a 'sprite':

Demo



来源:https://stackoverflow.com/questions/8363535/how-to-position-an-image-sprite-at-the-bottom-of-an-element-of-unknown-height

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!