Bootstrap 4 使表格标题在滚动时固定,但列宽度仍会根据正文行中的内容动态更改

Bootstrap 4 使表格标题在滚动时固定,但列宽度仍会根据正文行中的内容动态更改,bootstrap-4,Bootstrap 4,所以我的问题是,在向下滚动窗口时,我需要一个具有固定标题的表,但是如果我使用position:fixed,那么我需要为列标题设置一个手动宽度,重点是它们需要根据内容展开。 因为如果不是,当正文上的内容有更多文本时,它们往往会重叠到下一个列标题 这是我的密码: 你的问题值得怀疑 <table class="table table-striped col-md-12 table-condensed cf"> <thead class="table-bordered cf

所以我的问题是,在向下滚动窗口时,我需要一个具有固定标题的表,但是如果我使用position:fixed,那么我需要为列标题设置一个手动宽度,重点是它们需要根据内容展开。 因为如果不是,当正文上的内容有更多文本时,它们往往会重叠到下一个列标题

这是我的密码:

你的问题值得怀疑
<table class="table table-striped col-md-12 table-condensed cf">
      <thead class="table-bordered cf">
        <tr>
          <th>Name</th>
          <th>Last name</th>
          <th>Color</th>
          <th>Data</th>
          <th>More data</th>
          <th>Data</th>
        </tr>
      </thead>
      <tbody>
             <tr>
          <td > My Name</td>
          <td>Brown</td>
          <td>red</td>
          <td>sadfasf</td>
          <td>sfs</td>              
          <td>dsfsf</td>

        </tr>
             <tr>
          <td > My Name</td>
          <td>Brown</td>
          <td>red</td>
          <td>sadfasf</td>
          <td>sfs</td>              
          <td>dsfsf</td>

        </tr>
             <tr>
          <td > My Name</td>
          <td>Brown</td>
          <td>red</td>
          <td>sadfasf</td>
          <td>sfs</td>              
          <td>dsfsf</td>

        </tr>
             <tr>
          <td > My Name</td>
          <td>Brown</td>
          <td>red</td>
          <td>sadfasf</td>
          <td>sfs</td>              
          <td>dsfsf</td>

        </tr>
             <tr>
          <td > My Name</td>
          <td>Brown</td>
          <td>red</td>
          <td>sadfasf</td>
          <td>sfs</td>              
          <td>dsfsf</td>

        </tr>
             <tr>
          <td > My Name</td>
          <td>Brown</td>
          <td>red</td>
          <td>sadfasf</td>
          <td>sfs</td>              
          <td>dsfsf</td>

        </tr>
             <tr>
          <td > My Name</td>
          <td>Brown</td>
          <td>red</td>
          <td>sadfasf</td>
          <td>sfs</td>              
          <td>dsfsf</td>

        </tr>
             <tr>
          <td > My Name</td>
          <td>Brown</td>
          <td>red</td>
          <td>sadfasf</td>
          <td>sfs</td>              
          <td>dsfsf</td>
      </tbody>
    </table>
  thead{
  position:fixed; }