开发者

resizing css sprite

开发者 https://www.devze.com 2023-03-10 18:28 出处:网络
I\'ve an image of dimension some 500X400 px (background.png) and then an HTML div of width 150X100 px.

I've an image of dimension some 500X400 px (background.png) and then an HTML div of width 150X100 px.

I want to show the portion of the image background.png from top-left (x: 50, y: 50) to bottom-right (x1: 350, y1: 250) inside the div.

The dimension of the portion of background.png I want to show is 300X200, which is twice the size of the HTML div.

How do I resize the image p开发者_开发百科ortion so that it fits within the dimension of the div and display it using CSS or jquery.


You can use background-position: -50px -50px and the CSS3 background-size: 50% to achieve this result.

background-size isn't supported by old browsers, you can check support here.

0

精彩评论

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

关注公众号