调整图像的 jQuery 调整大小,使其一开始不会显得很大

发布于 2024-09-14 01:40:49 字数 327 浏览 1 评论 0原文

各位,抱歉,这个标题有点尴尬。

无论如何,我正在尝试使用以下 jQuery 片段调整图像大小:

$(window).load(function(){
$('img.FancyBox').each(function(){
$(this).width($(this).width() * 0.25);
});
});

现在,这可以工作,但如果我能找到一种方法来指定图像加载其原始大小的 25%,而不是加载,那就太好了它们的原始大小,并按比例缩小。

它有效,但看起来有点奇怪。

任何类型的解决方法都会很棒!

谢谢!

Kind of an awkward title guys, sorry.

Anyway, I'm trying to resize my images with the following snippet of jQuery:

$(window).load(function(){
$('img.FancyBox').each(function(){
$(this).width($(this).width() * 0.25);
});
});

Now, this works, but it would be really nice if I could find a way to specify the images to load 25% of their original size, rather than loading their original size, and scaling down.

It works, but it looks kind of odd.

Any sort of workaround would be great!

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

殊姿 2024-09-21 01:40:49

您可以在 CSS 中将 .FancyBox 设置为 display: none; ,然后执行以下操作:

$(window).load(function(){
    $('img.FancyBox').each(function(){
        $(this).width($(this).width() * 0.25);
        $(this).show();
    });
});

you could set .FancyBox to display: none; in your CSS and then do:

$(window).load(function(){
    $('img.FancyBox').each(function(){
        $(this).width($(this).width() * 0.25);
        $(this).show();
    });
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文