table caption goes bottom using bootstrap

2020-08-09 05:48发布

问题:

Table caption is at the top of the table but when I use a bootstrap class it goes to bottom of the table.

<table class="table table-bordered">
    <caption>why?</caption>
    <tr>
        <th>1</th>
        <th>2</th>
        <th>3</th>
    </tr>
    <tr>
        <th>4</th>
        <td>5</td>
        <td>6</td>
    </tr>
</table>

How do I align it to the top of table?

回答1:

That's because bootstrap 4 has default caption css style - caption-side: bottom

When you change caption-side: top; you will have your caption on the top of the table.