我不确定为什么会这样,因为我按照Zurb网站上的说明进行操作。使用TwentyTwenty打开页面时,窗口的大小无关紧要,只有在页面调整大小后才会显示滑块。该插件除此之外完美无瑕。我有一种感觉,有一些方法可以调整以下内容,使其加载而不调整窗口大小...
$(window).load(function() {
$(".twentytwenty-container").twentytwenty();
});
也许?非常感谢。
答案 0 :(得分:1)
这是一个小错误,但通过添加代码修复。 将其添加到jquery.twentytwenty.js文件:
$(window).load(function() {
$(window).trigger("resize.twentytwenty");
});

$.fn.twentytwenty = function(options) {
var options = $.extend({default_offset_pct: 0.5, orientation: 'horizontal'}, options);
// >>>>> HERE ADD CODE <<<<<<
return this.each(function() {
// .......
来源:https://github.com/zurb/twentytwenty/pull/69/commits/471a824bf5ab233797d0de689a5be105347c81e2
答案 1 :(得分:-1)
我长期以来一直坐在同一个问题上。我在代码中使用了类.twentytwenty-container
。当我将其切换为id(此处为#container-id
)时,问题似乎消失了。
$(window).load(function(){
$("#container-id").twentytwenty({
default_offset_pct: 0.5, // How much of the before image is visible when the page loads
orientation: 'horizontal' // Orientation of the before and after images ('horizontal' or 'vertical')
});
});
这对其他人有用吗?