垂直滚动在打破前一个tbody宽度的tbody中无法正常工作

时间:2016-04-26 08:02:53

标签: 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&gt;&gt;

之前添加div之前的表格

enter image description here

这是在tbody&gt;&gt;

之前添加div之后的表格

enter image description here

1 个答案:

答案 0 :(得分:0)

更改自:

<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;">