使用 AnythingSlider 幻灯片背景

发布于 2024-12-07 01:16:40 字数 305 浏览 0 评论 0原文

单击“下一个”箭头和“上一个”箭头时,我需要滑动背景 - 现在背景位于 #container 元素中 - 但是,这不起作用 - 我尝试将背景放在 ul#slider 上元素 - 但这也不起作用...

我需要的是背景将是滑块与滑块内的 li 一样多...

关于如何做到这一点有什么建议吗?

您可以在此处查看该项目:http://www.i-creative.dk/Slider/

谢谢

I need to slide a background when clicking the "next" arrow, and the "previous" arrow - right now the background is in the #container element - However, that doesnt work - I've tried putting the background on the ul#slider element - But that doesnt work either...

What i need is that the background will be slider as much as the liinside the slider...

Any suggestions on how to do that ?

You can see the project here: http://www.i-creative.dk/Slider/

thx

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

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

发布评论

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

评论(2

抱着落日 2024-12-14 01:16:40

我已经构建了类似您所要求的东西,这非常痛苦。

问题是,您所说的是每张幻灯片都有不同的背景图像、页面大小。

2 个选项是:
1:有一个大背景图像,所有背景水平对齐,并在更改 div 时对 css 背景位置进行动画处理,以保持匹配。这样做的好处是只需要下载一张图片,但是会很大。
问题是:如果一次跳多个步骤,您会看到所有其他图像;

它要求您使用固定宽度;

如果你只想改变一张幻灯片的背景,那就很痛苦了;

  1. 在 div 上预加载下一张幻灯片的背景,该 div 是 container 的同级,但具有更高的 z-index。使用 jquery 将其从适当的一侧滑过现有背景。
    这种方法的好处是,您可以使用 css 使背景图像始终占据屏幕的整个宽度,或者使用更大的成像器并将其居中。请参阅此处:http://cksk.com 示例。

长话短说,您无法使用现成的解决方案来解决这个问题,您需要亲自动手。

此外,您还需要花费大量时间进行优化。

I've built something like what you're asking for, and it's a total pain.

The problem is, you're talking about having a different background image, the size of the page, for EVERY slide.

2 options are:
1: Have one BIG background image, with all the background aligned horizontally, and animate the css background-position when you change a div, to keep things matching. This ahs the advanatage that only one image needs to be downloaded, but it will be big.
Problems are: you see all the other images if you jump multiple steps at once;

it requires that you use a fixed width;

it's a pain if you want to change the background for just one slide;

  1. Preload the background for the next slide on a div which is a sibling of container but has a higher z-index. Use jquery to slide this over the existing background, from the appropriate side.
    The good thing about this method is that you can use css to make the background image always take up the full-width of the screen, or use a bigger imager and have it centred. See here: http://cksk.com for an example.

Long story short, you won't get this working with an off-the-shelf solution, you'll need to get your hands dirty.

Also, you'll need to spend a hell of a lot of time on optimisation.

云朵有点甜 2024-12-14 01:16:40

试试这个CSS...

#slider {
    width: 472px; /* divided the width of the background image by 4 (# of panels) */
    height: 570px;
    list-style: none;
    /* start background after the initial cloned panel: 472px to match panel width */
    background: transparent url(../images/background.png) 472px 0 repeat-x;
}

/* This makes sure the last cloned panel background matches the first panel */
ul#slider li.clone {
    background: transparent url(../images/background.png) 0 0 repeat-x !important;
}

/* Make the background visible */
div.anythingSlider .anythingWindow {
    overflow: visible !important;
}

唯一的问题是UL的宽度是有限的,所以当你到达最后一个面板时,背景结束,但一旦你点击右箭头,背景就会重新出现。

Try this css...

#slider {
    width: 472px; /* divided the width of the background image by 4 (# of panels) */
    height: 570px;
    list-style: none;
    /* start background after the initial cloned panel: 472px to match panel width */
    background: transparent url(../images/background.png) 472px 0 repeat-x;
}

/* This makes sure the last cloned panel background matches the first panel */
ul#slider li.clone {
    background: transparent url(../images/background.png) 0 0 repeat-x !important;
}

/* Make the background visible */
div.anythingSlider .anythingWindow {
    overflow: visible !important;
}

The only problem is that the width of the UL is limited, so when you get to the last panel, the background ends, but reappears once you hit the right arrow.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文