CSS:带有文本的液体条不会扩展

发布于 2024-07-12 02:54:23 字数 326 浏览 4 评论 0原文

我有一个水平条的宽度100%。 在水平栏中,我的文本在 978px 容器内左对齐。 每当浏览器窗口缩小到宽度小于 978px 时,页面底部就会出现一个滚动条。 每当我向右滚动时,该栏不再跨越页面的宽度,而是留在后面。 我明白为什么会发生这种情况,但我不知道该怎么做才能解决它。 如果您有任何想法,请告诉我。 谢谢你!

示例页面

I have a horizontal bar that has been given a width of 100%. Within the horizontal bar, I have text that is left-aligned within a 978px container. Whenever the browser window is shrunk so that it is less than 978px wide, a scrollbar along the bottom of the page appears. Whenever I scroll to the right, the bar no longer spans the width of the page but instead, is left behind. I understand why this happens, but I don't know what to do to fix it. If you have any ideas, let me know. Thank you!

An example page

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

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

发布评论

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

评论(2

童话 2024-07-19 02:54:23

好吧,你已经将 #header 设置为 100% 的包含块(这将是主体)。 当缩小正文时,标题的宽度也会缩小。 如果主体的宽度小于容器的宽度,则黑条不会完全延伸。

您到底希望它做什么?

-没有滚动条:取出容器,使用#header将文本居中

-黑条扩展整个距离:解决这个问题的最简单方法是为容器提供背景颜色。

well, you have #header set to 100% of it's containing block (which would be the body). When you shrink the body, the header's width shrinks. If the body's width is less than the container's width, the black bar will not extend the whole way.

What exactly would you rather it did?

-not have a scroll bar: take out the container, center the text using #header

-the black bar expands the whole distance: The easiest way to solve that is to give the container a background-color.

陌路终见情 2024-07-19 02:54:23

更改:

width: 978px;

至:

max-width: 978px

这似乎在 FF3、IE7 和 chrome 中有效。

Change:

width: 978px;

to:

max-width: 978px

That seemed to do the trick in FF3, IE7 and chrome.

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