jQuery Cycle 插件可扩展 DIV 和 containerResize=1
我在页面上使用 jQuery Cycle(完整)插件,其中使用宽度为 75% 的容器 DIV (.content-left) 和该容器内的 jQuery Cycle 幻灯片。该容器内的图像应该自动调整。
我使用:
JS:
$('.slides').cycle({
fx: 'fade',
containerResize: 1 // default for jquery.cycle.all
});
HTML:
<div id="content">
<div class="content-left">
<div class="slides">
<img src="...">
<img src="...">
<!-- etc. -->
</div>
</div>
<div class="content-right">
some text
</div>
<div class="clear"></div>
</div>
CSS:
#content {
overflow:hidden;
}
#content .content-left {
width:75%;
float:left;
}
#content .content-left img { /* or: .slides img */
width:100% !important;
position:relative;
left:0px;
top:0px;
z-index:-2;
}
#content .content-right {
width:25%;
float:right;
}
On Page init 我的包装 DIV (.content-left) 的高度和宽度得到了很好的调整,这要归功于 containerResize 函数。但是,当我调整浏览器窗口大小时,幻灯片的宽度和高度保持不变,这不是我想要的。
containerResize: 0 也没有带来所需的效果(然后它会忽略图像的高度并将包装器的高度调整为 .content-right 的高度(并剪掉图像))。
当我仅使用图像而不加载 Cycle 时,一切正常。
有什么解决办法吗?
谢谢!
I am using the jQuery Cycle (full) Plugin on a page where I am using a container DIV (.content-left) with a width of 75% and a jQuery Cycle slideshow inside of that container. The images inside of that container should be adjusted automatically.
I use:
JS:
$('.slides').cycle({
fx: 'fade',
containerResize: 1 // default for jquery.cycle.all
});
HTML:
<div id="content">
<div class="content-left">
<div class="slides">
<img src="...">
<img src="...">
<!-- etc. -->
</div>
</div>
<div class="content-right">
some text
</div>
<div class="clear"></div>
</div>
CSS:
#content {
overflow:hidden;
}
#content .content-left {
width:75%;
float:left;
}
#content .content-left img { /* or: .slides img */
width:100% !important;
position:relative;
left:0px;
top:0px;
z-index:-2;
}
#content .content-right {
width:25%;
float:right;
}
On Page init my wrapping DIV's (.content-left) height and width get's adjusted just fine thanks to the containerResize function. However when I resize my browser window, the width and height of the slides stay the same, which is not what I wanted.
containerResize: 0 doesn't bring the desired effect either (it then ignores the height of the images and adjusts the height of the wrapper to the height of .content-right (and cuts off the image)).
When I am using only an image without loading Cycle at all everything works fine.
Any solutions for that?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在JS中设置:(
真的!)然后在容器div中使用透明图像的技巧。请参阅此处
详细信息。
Set in JS:
(really!) and then use the trick of transparent image in the container div. See here
for detail.
如何在图像上尝试
max-width: 100% !important;
,并从width: 100% !important
中删除!important
,这样当 Cycle 尝试将幻灯片大小调整回原始宽度时,您的最大宽度定义将优先。如果你能提供一个jsfiddle,那也会有很大的帮助。
How about trying
max-width: 100% !important;
on the images, and remove the!important
from thewidth: 100% !important
, so that when cycle attempts to resize your slides back to the original width, your max-width definition will take precedence.If you could provide a jsfiddle, that would also be of great help.