等距行图像未对齐 html / css

发布于 2024-10-20 04:48:15 字数 658 浏览 2 评论 0原文

我有一个网站,其中 3 个页面有一行图像,可以在鼠标悬停时查看更大的图像。在 2 页上,对齐效果很好,一行中有 6 个图像。无法正常工作的第三页每行有 5 个图像。

包含 6 个图像的页面完美对齐 - 最左边的图像独立存在,向左浮动,其他 5 个图像位于 div(移动器行)内自己的 div 中,并且间隔 20%。此工作页面的代码位于: http://jsfiddle.net/AvNJY/

所以使用相同的逻辑我尝试让只有 5 个图像的行进行对齐,再次执行与上面相同的操作并将距离设置为 25%。这使得该行中的最后一个图像跳到其他图像下方。我研究了这个百分比,由于某种原因,当以 100% 的比例查看时,24.4% 看起来似乎在除 Firefox 之外的所有浏览器中都正确对齐。然而,一旦您在任何浏览器中放大站点,最后一个图像就会再次跳到其他图像下方(在 Firefox 中,这种情况会自动发生)。我想知道我在这个页面上做错了什么,因为我已经尝试了我能想到的一切 - 并且无法理解为什么 25% 的人不这样做。此页面的代码位于: http://jsfiddle.net/9K74d/

我非常感谢一些帮助如果有人知道答案。提前致谢!

I have a site where 3 pages have a row of images that can be viewed larger upon rollover. On 2 pages the alignment works fine, these have 6 images in the row. The third page which is not working properly has 5 images per row.

The pages with 6 images are aligning perfectly - the left-most image is on its own, floating left, the other 5 are in their own divs within a div (movers-row) and are spaced 20% apart. The code for this working page is here: http://jsfiddle.net/AvNJY/

So using the same logic I tried to get the row with only 5 images to align, again doing the same as above and setting the distance to 25%. This made the last image in the row jump below the others. I played around with the percentage and for some reason at 24.4% it looks as if it's aligning correctly in all browsers apart from Firefox, when viewed at 100%. However as soon as you enlarge the site in any browser, the last image jumps again below the others (in Firefox this happens automatically). I am wondering what I am doing wrong on this page as I've tried everything I can think of - and can't understand why the 25% isn't doing it. The code for this page is here: http://jsfiddle.net/9K74d/

I would really appreciate some help if anyone knows the answer. Thanks in advance!

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

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

发布评论

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

评论(2

城歌 2024-10-27 04:48:15

您在 jsfiddle 中的示例不清楚,但请尝试以下操作:

#studiomovers-row 添加 overflow:auto 并删除此 id 的 margin

Your example in jsfiddle, is not clear but try the following:

add overflow:auto for #studiomovers-row and remove the margin of this id.

阳光的暖冬 2024-10-27 04:48:15

这可能是一个舍入错误 - 浏览器的数学能力可能出人意料地差,并会产生意外的舍入错误。将你的百分比降低到 24 甚至 23,看看是否有效。您始终可以尝试将图像放入单个 div 容器中,调整大小为正确的预期大小,并设置溢出:隐藏,以防出现一两个像素溢出。这给了你一点误差,这比布局中断要好得多。

It's probably a rounding error - browsers can be surprisingly poor at math and make unexpected rounding errors. Knock your % down to 24 or even 23 and see if that works. You can always try putting the images into a single div container, sized to the correct, expected size, and set overflow: hidden in case there is a pixel or two that runs over. That gives you a little margin of error and it's much better than having the layout break.

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