jQuery - 可能将背景图像大小调整为设置大小? [英] jQuery - possible to resize background-image to a set size?

查看:231
本文介绍了jQuery - 可能将背景图像大小调整为设置大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个情况,我迫切需要适合一个div的背景图像到一定的大小。有谁知道这是否可能与jQuery?我知道它需要的大小,它不必调整大小的div的大小。 35,000张图片已缩放到错误的大小,需要上线才能调整图片大小,这不是一个选择!

I'm in a situation where I urgently need to fit a background image of a div to a certain size. Does anyone know if this is possible with jQuery? I know the size it needs to be, it doesn't have to resize with the size of the div. 35,000 images have been scaled to the wrong size and it needs to go live so resizing the images isn't an option!

任何建议赞赏!

编辑:我只是看看我们是否能够改变HTML来从DIV中取出背景图片,并将其放在一个单独的绝对定位的div中,与IMG标签相同

I'm just seeing whether we're able to alter the HTML to take the background image out of the DIV and put it in a separate absolutely positioned div at the same with an IMG tag in it... the IMG tag can then be resized with CSS.

推荐答案

您可以使用CSS3更改背景大小。具有此功能的浏览器包括Opera,Safari,Chrome,Firefox,Konqueror和IE9:

You can use CSS3 to change the background size. The browsers that have this feature implemented are Opera, Safari, Chrome, Firefox, Konqueror and IE9:

.myClass
{
    -o-background-size: 200px 50px;
    -webkit-background-size: 200px 50px;
    -khtml-background-size: 200px 50px;
    -moz-background-size: 200px 50px;
    background-size: 200px 50px;
}

不确定背景尺寸的jQuery实现。

Not sure about the jQuery implementation of background size.

在这种情况下,也许本文< a>会帮助你。

In this case, maybe this article will help you.

这篇关于jQuery - 可能将背景图像大小调整为设置大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆