html - 垂直滚动在 tbody 中无法正常工作,打破了之前的 tbody 宽度

标签 html css

我有一个表格,我需要在 tbody 中添加一个垂直滚动条。我看过一些代码但不适合我或者我不理解。我也不太擅长CSS。我添加了一个 div 并将我的 tbody 放在那里。它适用于滚动,但 tbody 宽度变小了。

这是我的表格:

<table id="familyHist" class="table table-striped table-bordered">
    <thead>
    <tr>
        <th colspan="{{(relationCount + 1)}}" class="info">
            <g:if test="${session.userIsPatient}">
                Please click the appropriate box to indicate family history for a given category or medical issue.
            </g:if>
            <g:else>
                Please click the appropriate box to indicate positive family history.
            </g:else>
        </th>
    </tr>
    <tr>
        <th></th>
        {{#each relations}}
            {{#if .relation !== 'Uncles' && .relation !== 'Aunts'}}
                <th class="text-center">{{relation}}*</th>
            {{else}}
                <th class="text-center">{{relation}}</th>
            {{/if}}
        {{/each}}
    </tr>
    </thead>
    <div style="width: inherit; overflow-y:scroll; height:100px; overflow-x: hidden;">
    <tbody>
    {{#each rows: index}}
    <tr id="familyHistoryRow-{{symptomId}}">
        <td>
            <input type="hidden" name="familyHistId" value={{familyHistId}}/>
            {{description}}
        </td>
        {{#if isUserDefined}}
        <td colspan="8">
            <div class="-fluid">
                <form class="form-inline">
                    <div class="col-sm-9 col-md-8 col-lg-7 form-group">
                        <g:render template="/patient/familyHist/textarea" />
                    </div>
                    <div class="col-sm-3 col-md-4 col-lg-5 form-group">
                        <g:render template="/patient/familyHist/buttons" />
                    </div>
                </form>
            </div>
        </td>
        {{else}}
        {{#each relationMap}}
        <td class="text-center">
            <g:render template="/patient/familyHist/checkbox" />
        </td>
        {{/each}}
        {{/if}}
    </tr>
    {{/each}}
    </tbody>
    </div>
</table>

这是在 tbody 之前添加 div 之前的表格:

enter image description here

这是在 tbody 之前添加 div 之后的表格:

enter image description here

最佳答案

更改自:

<div style="width: inherit; overflow-y:scroll; height:100px; overflow-x: hidden;">
<tbody>

<tbody style="width: inherit; overflow-y:scroll; height:100px; overflow-x: hidden;">

关于html - 垂直滚动在 tbody 中无法正常工作,打破了之前的 tbody 宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36858860/

相关文章:

css - 我如何使用 li :hover to change the WHOLE li color?

html - 使文本框使用剩余空间

php - 如何为事件菜单项提供不同的样式

html - 如何删除页脚下的空间?

javascript - 如何禁用移动浏览器的滚动?

html - Bootstrap 3 - 两列布局 - 摆脱占位符

css - 与 css 文件中的类名冲突

javascript - 选项卡无法正常工作

javascript - jqueryMobile 应用程序无法使用 jquryMobile 框架 js 和 css 文件相对路径

html - 如何在 Perl CGI 文件中正确呈现 HTML 表