简体   繁体   中英

change table column width

I'm using react library that constructs table in the following template:

    <div class="table-container" style="width:100%">
    <table style="width:100%">
        <thead>
            <tr>
                <th>BLA_Column</th>
            </tr>
        </thead>
    </table>
    <table style="width:100%">
        <tbody>
            <tr>
                <td>BLA_Body</td>
            </tr>
        </tbody>
    </table>
</div>

I'm able to set the width of the th and the td to auto, but, the result is that I get two different sizes (one for the th and one for the td). When I try to use the following selector (for example), nothing happens:

table > thead > th {
    width: 100px;
}

Also when I try to change directly the width using the chrome dev-tools, there is no change at all.

Thanks ahead!

CSS character > select only direct childs. Change your CSS with :

table > thead th {
    width: 100px;
}

or

table > thead > tr > th {
    width: 100px;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM