开发者

Is there a way to scale background-image style?

If I put the regular img tag in html, I can basically specify width and height and browser will scale the image. As long as dimensions are not too far off from the original, the result is decent.

For example, the avatar image is scaled to 32x32 even though original is 45x45

<img width="32" height="32" alt="" src="http://www.google.com/friendconnect/scs/images/NoPictureDark.png">

Is there any way to scale the image in the css background-image, like this?

<div class='avatar' style='background-image:url("hhttp://www.google开发者_Go百科.com/friendconnect/scs/images/NoPictureDark.png");'>

I basically want to show avatar as a property of background-image instead of usual img tag and also need to scale it to size.

Is there any known trick that can do that?


This is only possible in CSS3 using the background-size property. See spec and compatibility table.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜