CSS-背景颜色未填充到滚动 div 的顶部

发布于 2024-08-24 06:11:30 字数 671 浏览 4 评论 0原文

我有一个 div(带有滚动条的页面子区域),其中包含一些文本、图像和表格。 为 div 定义的背景颜色 -

<div style="background-color: white">

不会将区域填充到顶部,滚动条的顶部箭头位于填充背景颜色的区域上方(大约一行的宽度)。在顶部添加 br 可以修复它,但会将内容移得太低。

我读到了两个可能的解决方案。有人建议我为 div 设置一个固定的高度。这需要每次更改页面内容时通过反复试验来更改高度。下一个。另一个建议是在最后添加这个,就在 /div 之前 -

</div>
<div class="clear"></div>
</div>

但这没有效果。

有几个不同的页面使用 SSI 加载到滚动区域,其中一些包含的页面使用 div,其中一些是浮动的,一些是绝对的。

感谢您的任何帮助。

编辑

添加以下内容,我没有意识到“清除”需要它,但仍然

<style type="text/css">
.clear {
clear:both;
height:1px;
overflow:hidden;}
</style>

不起作用

I have a div (sub area of page with scroll bar) that has some text, an image and a table.
The background color defined for the div -

<div style="background-color: white">

does not fill the area to the top, the top arrow of the scroll bar is above the area filled with the background color (by about the width of one line). Adding a br at the top fixes it, but moves stuff too far down.

I read two potential solutions. One suggested I set a fixed height for the div. That would require changing the height by trial-and-error every time I changed the content of the page. Next. The other suggestion said to add this at the end, just before the /div -

</div>
<div class="clear"></div>
</div>

but that has no effect.

There are several different pages that get loaded into the scrolling area, using SSI's, and some of those included pages use divs, and some of those are floats and some absolutes.

Thanks for any help.

EDIT

Adding the following, which I didn't realize was needed with the "clear", still doesn't work

<style type="text/css">
.clear {
clear:both;
height:1px;
overflow:hidden;}
</style>

Ad

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

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

发布评论

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

评论(1

殊姿 2024-08-31 06:11:31

我刚刚写了这个,无论你在其中放入多少内容,它似乎都会保留背景颜色...

<div style='background:#abc;overflow:auto;'>
    <p>a bunch of content goes here</p>
</div>

当然,你可以设置一个高度,但更有可能它会在某些 div 包装中...

I just wrote this up and it seems to keep the background color no matter how much content you put in it...

<div style='background:#abc;overflow:auto;'>
    <p>a bunch of content goes here</p>
</div>

you can, of course, set a height to that but more likely it would be in some div wrapper...

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