奇怪的 CSS 行为

发布于 2024-12-01 16:34:25 字数 290 浏览 0 评论 0原文

我正在为一个网站做 HTML 和 CSS,我遇到了一个非常奇怪的错误/行为,我无法确定。

看看http://www.atelierhsl.nl/antwerp/。顶部的徽标有一条白线穿过。如果我在页面底部显示:无导航,它就会消失。但是当我增加文本列(.entry-content)的底部填充时,它会再次出现。这种情况发生在 Webkit、Mozilla 和 IE 中,所以我知道我一定做错了什么。我就是不明白是什么。有人吗?

I'm doing HTML and CSS for a site, and I've come across a very weird bug / behaviour that I can't pin down.

Take a look at http://www.atelierhsl.nl/antwerp/. There's a white line through the logo at the top. If I display:none the navigation at the bottom of the page, it disappears. But when I increase the bottom padding of the text column (.entry-content) it reappears again. This happens in Webkit, Mozilla and IE, so I know I must be doing something wrong. I just can't figure out what. Anybody?

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

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

发布评论

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

评论(4

梦忆晨望 2024-12-08 16:34:25

这是由身体背景图像顶部的抗锯齿线(仅 1 个浅灰色像素)引起的。简单的答案是使用图像编辑器裁剪它。
您可能希望将图像与顶部对齐:

background: url("/wp-content/themes/transfer/images/bg.jpg") no-repeat scroll center top #1D1D88

主要问题是背景图像没有它应覆盖的区域那么大。

This is caused by an anti-aliased line on the top your body's background images (just 1 pixel of light gray). The simple answer is to crop it using an image editor.
You may want to align the image to the top:

background: url("/wp-content/themes/transfer/images/bg.jpg") no-repeat scroll center top #1D1D88

The main problem is that the background image isn't as big as the the area it should cover.

森林很绿却致人迷途 2024-12-08 16:34:25

Kobi 的答案是正确的,但如果您不介意设计建议:不要将黑色背景图像放在正文的不重复顶部,而是将正文内容分离到容器和页脚中。对于内容背景,使用较小的背景图像并将其平铺,或将背景颜色设置为黑色,因为看起来没有渐变。然后,页脚 div 可以具有白色背景(从正文继承,或直接分配)。

您的页面在逻辑上分为主要内容和页脚,因此 HTML 应该表达这一点。

Kobi's answer is correct, but if you don't mind a design suggestion: Rather than putting a black background image at no-repeat top for the body, separate body content into a container and a footer. For the content background use a smaller background image and tile it, or set the background color to black, since it appears you have no gradient. The footer div can then have a white background (inherited from the body, or just assigned directly).

You page is logically divided into main content and a footer, so the HTML should express that.

一萌ing 2024-12-08 16:34:25

有两种解决方案:

  1. 只需将 body padding top 从 60 更改为 40 或者
  2. 将背景位置从 center center 更改为 center top

There is two solutions:

  1. Just changed the body padding top from 60 to 40 or
  2. changed the background position from center center to center top
吲‖鸣 2024-12-08 16:34:25

我认为,你应该从背景中剪下一条 1px 的线并重复它。不会有任何错误,并且您将减少图像权重。

I think, you should cut a 1px line from your background and to repeat-y it. There will be no bug, and you will decrease the image weight.

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