处理表中的溢出

发布于 2024-08-05 21:35:50 字数 439 浏览 2 评论 0原文

如果我有一个像这样非常非常简单的例子:

table {
    table-layout:fixed;
    width:300px;
}

.td1 {
    width:100px;
}
.td2 {
    width:200px;
}

并且在我的一个 .td2 中包含一个图像,可以说,宽度为 300px代码>.我想显示滚动条以允许用户滚动以查看全部内容。但我认为这是不可能的,是吗?

所以我的问题是:

  1. 除了 hidden 之外,还有其他选项用于处理表中的溢出吗?

  2. 是否可以仅当内容超出设定宽度时才显示滚动条? (我发誓我在一些论坛软件中见过它,但我不记得是哪一个)

If I have a table like this very very simple example:

table {
    table-layout:fixed;
    width:300px;
}

.td1 {
    width:100px;
}
.td2 {
    width:200px;
}

and in one of my .td2 contains an image that is, lets say, 300px in width. I would like to show scroll bars to allow users to scroll to see it all. However I don't think this is possible, is it?

So my questions are:

  1. Are there any other options apart from hidden for handling overflow in tables?

  2. Is it possible to show scroll-bars only when content pushes beyond a set width? (I swear I've seen it in some forum software but I can't remember which one)

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

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

发布评论

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

评论(1

和我恋爱吧 2024-08-12 21:35:50

怎么样

overflow: auto

内容被剪裁并且滚动
仅在必要时添加。

将图像放入表格单元格的 div 内,并使 div 的宽度和高度为 td 的 100%,并将其样式设置为溢出:auto

<style>
.test { width: 100%; height: 100%; overflow: auto; } 
</style>

<td>
<div class="test">
your image
</div>
</td>

What about

overflow: auto

Content is clipped and scrolling is
added only when necessary.

Put the image inside a div in the table cell and make the width and height of the div to be 100% of the td and style it to overflow: auto

<style>
.test { width: 100%; height: 100%; overflow: auto; } 
</style>

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