0

这是我的横幅图像存储在 javascript 中的位置:

```

/*
    Background slideshow
*/
$('.top-content').backstretch("assets/img/backgrounds/Banner_1024 x 768.jpg");
$('.testimonials-container').backstretch("assets/img/backgrounds/testimonial1.jpg");

$('a[data-toggle="tab"]').on('shown.bs.tab', function(){
$('.testimonials-container').backstretch("resize");
});

```

我想为移动设备和其他屏幕尺寸添加另一个版本的横幅图像。我是否将它们添加到这里的 javascript 中?如何链接媒体查询中的所有内容?

4

1 回答 1

1

您正在使用 jQuery 插件 Backstretch。

快速查看 https://github.com/jquery-backstretch/jquery-backstretch上的文档表明这是一个内置功能。只需传递一组图像和宽度。

// Or, to automatically choose from a set of resolutions.
// The width is the width of the image, and the algorithm chooses the best fit.
$(".foo").backstretch([
  [
    { width: 1080, url: "path/to/image1_1080.jpg" },
    { width: 720, url: "path/to/image1_720.jpg" },
    { width: 320, url: "path/to/image1_320.jpg" }
  ]
]);
于 2018-02-12T06:34:21.740 回答