DIV 内图像的填充/边距

发布于 2024-10-05 06:10:56 字数 380 浏览 7 评论 0原文

好的。我最近对此网站进行了一些更新。

http://annberingerart.com/index.php

进行一些细微的更改后,边距和填充似乎因为索引页上的图像已更改。我希望所有图像之间的垂直和水平填充均相等,并且边距一致。

此外,我在朋友安装了 Safari 5 的 MAC 上查看该网站时,整个包装器的大小似乎有所缩小,因为它无法像我进行更改之前那样包含其子级。

你可以看一下 firebug 中的 CSS,因为在这里发布 400 多行 CSS 会显得冗长且过多。

欢迎任何和所有的批评,但我最想要的是如何解决这个问题的建议。

Ok. I recently made some updates to this website.

http://annberingerart.com/index.php

Upon making some minor changes it seems that the margin and padding for the images on the index page has changed. I would like for there to be equal padding both vertically and horizontally between all images as well as a consistent margin.

In addition, I was viewing the website on a friend's MAC with Safari 5 installed and the entire wrapper seemed to have shrunk in size because it could not contain its children as it had before I made the changes.

You can take a look at the CSS in firebug as it would be lengthy and excessive to post 400+ lines of CSS on here.

Any and all criticism is welcome, but I mostly want advice on how to fix this issue.

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

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

发布评论

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

评论(1

彻夜缠绵 2024-10-12 06:10:56

您的水平边距是由空格/换行符引起的,因为图像是内联元素(实际上是内联块......)。

如果您浮动图像,您将可以更好地控制精确的边距,而不是依赖于空格/换行符的宽度。

要解决您的问题,您可以:

  • 将图像向左浮动;
  • 给包装器一个左填充,没有右填充和一个overflow:hidden
  • 为所有图像提供右填充(与包装器的左填充相同)。

Your horizontal margin is caused by spaces / new-lines because the images are inline elements (sort of inline-block really...).

If you float the images, you will have more control over the exact margins instead of depending on the width of a space / new-line.

To solve your problem, you could:

  • float the images left;
  • give the wrapper a left-padding, no right-padding and an overflow:hidden;
  • give all images a right padding (the same as the left-padding of the wrapper).
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文