jQuery Cycle - 在右侧对齐不同尺寸的图像?

发布于 2024-11-16 14:31:04 字数 815 浏览 5 评论 0原文

我有一个幻灯片(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 技术交流群。

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

发布评论

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

评论(4

奶气 2024-11-23 14:31:04

当我尝试右对齐容器中的某些内容时,我也遇到了这个问题。这个解决方案对我们有用:

$('#sltitles span').each(function() {
  $(this).css({right: '0'});
}); 

您需要在主插件之前运行它,才能将其应用于看起来的所有内容。我们最终得出:

<script type="text/javascript">
  $(document).ready(function() {
    $('#sltitles span').each(function() {
      $(this).css({right: '0'});
    });
    $('#sltitles').cycle({
      fx: 'fade'
    });
  });
</script>

也许这会帮助其他遇到同样问题的人。

I also came across this problem, when I was trying to right-align some content within a container. This solution worked for us:

$('#sltitles span').each(function() {
  $(this).css({right: '0'});
}); 

You need to run it before the main plugin for it to apply to all content it seems. We ended up with:

<script type="text/javascript">
  $(document).ready(function() {
    $('#sltitles span').each(function() {
      $(this).css({right: '0'});
    });
    $('#sltitles').cycle({
      fx: 'fade'
    });
  });
</script>

Maybe this will help someone else having the same problem.

对你的占有欲 2024-11-23 14:31:04

Cycle 插件对图像使用绝对位置,还有 top: 0;left: 0;,因此您必须编辑插件代码,因为它不是eplugin 的选项。

只需打开插件文件并搜索 left:0 并将其更改为 right:0 即可。

如果您更新插件,则只需再次执行此操作即可。

Cycle plugin uses position absolute for the images, also top: 0; and left: 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 to right:0.

You will just have to do it again if you update the plugin.

り繁华旳梦境 2024-11-23 14:31:04

这是一个非常简单的直接 CSS 解决方案,不涉及破解插件或大量臃肿的额外 jQuery 代码。

p.slideshow img {
    left: auto !important;
    right: 0 !important;
}

这也适用于非图像幻灯片项目:

div.cycle-slide {
    left: auto !important;
    right: 0 !important;
}

Here's a very simple straight-up css solution that doesn't involve hacking the plugin or a lot of bloated extra jQuery code.

p.slideshow img {
    left: auto !important;
    right: 0 !important;
}

This will also work well for non-image slide items:

div.cycle-slide {
    left: auto !important;
    right: 0 !important;
}
歌枕肩 2024-11-23 14:31:04

我会尝试在 div 中浮动图像:

<div class="slideshow">
 <img src="31.jpg" alt="" />
 <img src="35.jpg" alt="" />
 <img src="36.jpg" alt="" />
</div>


div.slideshow {
position:absolute;
top:0;
right:0;
z-index:-999;
overflow:hidden;
background: url(images/stripe-bg.png) repeat;
margin:0;
padding:0;

/* width:;
height:;*/ }



 div.slideshow img { float:right: display:inline}

I would try floating the images within a div :

<div class="slideshow">
 <img src="31.jpg" alt="" />
 <img src="35.jpg" alt="" />
 <img src="36.jpg" alt="" />
</div>


div.slideshow {
position:absolute;
top:0;
right:0;
z-index:-999;
overflow:hidden;
background: url(images/stripe-bg.png) repeat;
margin:0;
padding:0;

/* width:;
height:;*/ }



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