18910140161

HTML-CSS表在使用“width:100%”时超出网格列宽度-堆栈溢出

顺晟科技

2022-10-19 12:16:36

134

我通过另一个问题获得了帮助,以便创建一个根据列的内容调整列大小的表,以及其他一些条件: CSS表的宽度和列宽均为100%

这个表通常可以工作,但是当我在网格中使用它时,它会溢出它的列的边界。 下面是一个可以看到的例子: https://codepen.io/melonfacedoom/pen/powkavv

来自CodePen的HTML:

<div class="two-column-wrapper">
        <article class="two-column-article left-content">
            <h1 class="title purple-light-1">left side</h1>
            <p>some text</p>
        </article>
        <article class="two-column-article right-content">
            <h1 class="title green">right side</h1>
            <table class="content-table">
                <thead>
                    <tr>
                        <th>Example</th>
                        <th>Example</th>
                        <th>Example</th>
                        <th>Example</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Example</td>
                        <td>Example</td>
                        <td>Example</td>
                        <td>Example</td>
                    </tr>
                    <tr>
                        <td>Example</td>
                        <td>ExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExampleExample</td>
                        <td>Example</td>
                        <td>Example</td>
                    </tr>
                    <tr>
                        <td>Example</td>
                        <td>Example</td>
                        <td>Example</td>
                        <td>Example</td>
                    </tr>
                    <tr>
                        <td>Example</td>
                        <td>Example</td>
                        <td>Example</td>
                        <td>Example</td>
                    </tr>
                    <tr>
                        <td>Example</td>
                        <td>Example</td>
                        <td>Example</td>
                        <td>Example</td>
                    </tr>
                </tbody>
            </table>
        </article>
    </div>

来自CodePen的CSS:

请注意,如果缩小浏览器,它将从左/右布局切换到上/下布局,并且表格不再溢出。

这是带有网格的bug吗?当表处于左/右两列布局时,如何让它正确地看到其父容器的宽度?


顺晟科技:

  • TAG:
相关文章
我们已经准备好了,你呢?
2024我们与您携手共赢,为您的企业形象保驾护航