启用溢出:滚动到 100% 宽度的表格单元格

发布于 2024-08-25 17:41:49 字数 222 浏览 5 评论 0原文

我正在尝试执行以下操作: http://www.pastebin.org/113337

我'我想知道为什么滚动不会发生?它只是拉伸桌子。尝试运行带有和不带有空格的代码:nowrap 并查看其有何不同。每当我应用 nowrap 时,我的桌子就会被拉长。我该如何避免这种情况?

I'm trying to do the following: http://www.pastebin.org/113337

I'm wondering why the scrolling won't take place? It just stretches the table. Try running the code with and without white-space: nowrap and see how it differs. Whenever I apply nowrap my table gets stretched. How do I avoid this?

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

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

发布评论

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

评论(1

听,心雨的声音 2024-09-01 17:41:49

我很确定这就是表格的工作原理;当其中一个单元格中有太多内容时,它们就会伸展。
尝试将

放入 中,然后对其应用宽度和溢出属性。

附录:

您的 table 的 CSS 宽度属性为 150px,而 div 的 CSS 宽度属性为 %100。尝试为

指定非百分比宽度...

<table>
    <tr>
        <td>
            <div style="150px;">
                <!-- wtv -->
            </div>
        </td>
    </tr>
</table>

或者尝试将整个 放入

> 具有固定宽度...

<div style="width:150px">
    <table>
    <!-- wtv -->
    </table>
</div>

...最后,我建议您将 CSS 放入外部 .css 文件中;)

I'm pretty sure that's just how tables work; they stretch when there's too much content in one of their cells.
Try putting a <div> inside your <td> and apply the width and overflow properties to that instead.

Addendum:

Your table has a CSS width property of 150px while the div has a percentage, %100. Try giving the <div> a non-percentage width...

<table>
    <tr>
        <td>
            <div style="150px;">
                <!-- wtv -->
            </div>
        </td>
    </tr>
</table>

Or try putting the whole <table> in a <div> with a fixed width...

<div style="width:150px">
    <table>
    <!-- wtv -->
    </table>
</div>

... lastly, I'd advise that you put your CSS in an external .css file ;)

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