jQuery Cycle - 在右侧对齐不同尺寸的图像?
我有一个幻灯片(jquery 循环),用作网站的背景。问题是我想在右侧对齐照片,它们有不同的尺寸,并且由于某种原因,宽度最小的照片没有向右对齐...我尝试像人一样将 img 放入 div 中互联网上提出了不同的建议,但无济于事。这可以在不编辑插件的情况下实现吗?
HTML:
<p class="slideshow">
<img src="31.jpg" alt="" />
<img src="35.jpg" alt="" />
<img src="36.jpg" alt="" />
</p>
CSS:
p.slideshow {
position:absolute;
top:0;
right:0;
z-index:-999;
overflow:hidden;
background: url(images/stripe-bg.png) repeat;
margin:0;
padding:0;
/* without setting the width and height 100% I get the
annoying scroll bar on the right if photos are big in height */
/*height:100%;
width:100%;*/
}
您有任何线索如何将它们全部向右对齐吗?
谢谢, 克里斯
I have a slideshow (jquery cycle) that I use for the background of a site. Problem is that I want to align the photos on the right and they have different dimmensions and for some reason the ones who have the smallest widths don't get aligned to the right... I tried to put the img's into divs like on person on the internet suggested and different things but to no avail. Is this possible without editing the plugin?
HTML:
<p class="slideshow">
<img src="31.jpg" alt="" />
<img src="35.jpg" alt="" />
<img src="36.jpg" alt="" />
</p>
CSS:
p.slideshow {
position:absolute;
top:0;
right:0;
z-index:-999;
overflow:hidden;
background: url(images/stripe-bg.png) repeat;
margin:0;
padding:0;
/* without setting the width and height 100% I get the
annoying scroll bar on the right if photos are big in height */
/*height:100%;
width:100%;*/
}
Do you have any clues how to align all of them to the right?
Thank you,
Cris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
当我尝试右对齐容器中的某些内容时,我也遇到了这个问题。这个解决方案对我们有用:
您需要在主插件之前运行它,才能将其应用于看起来的所有内容。我们最终得出:
也许这会帮助其他遇到同样问题的人。
I also came across this problem, when I was trying to right-align some content within a container. This solution worked for us:
You need to run it before the main plugin for it to apply to all content it seems. We ended up with:
Maybe this will help someone else having the same problem.
Cycle 插件对图像使用绝对位置,还有
top: 0;
和left: 0;
,因此您必须编辑插件代码,因为它不是eplugin 的选项。只需打开插件文件并搜索
left:0
并将其更改为right:0
即可。如果您更新插件,则只需再次执行此操作即可。
Cycle plugin uses position absolute for the images, also
top: 0;
andleft: 0;
, so you will have to edit the plugin code, because is not part of the options of th eplugin.Just open the plugin file and search for
left:0
and change it toright:0
.You will just have to do it again if you update the plugin.
这是一个非常简单的直接 CSS 解决方案,不涉及破解插件或大量臃肿的额外 jQuery 代码。
这也适用于非图像幻灯片项目:
Here's a very simple straight-up css solution that doesn't involve hacking the plugin or a lot of bloated extra jQuery code.
This will also work well for non-image slide items:
我会尝试在 div 中浮动图像:
I would try floating the images within a div :