首页 > 解决方案 > 影响表头的引导显示类

问题描述

我正在努力使我的网站更加用户友好,我有一个如下图所示的表格,它在具有引导类的列的文本下放置了行,以在较小的屏幕上删除它们。

我似乎无法摆脱这个问题。我正在使用标准引导程序 4 CSS。

我的表格代码如下所示,感谢帮助。

<div class='container mx-auto' style='width: 100%'>
    <table class='table table-hover' style='width: 100%'>
        <thead class='bg-primary text-white'>  
            <tr>
                <th class='bg-primary text-white border-left border-right d-none d-xl-block'>ID</th>
                <th class='col-2 bg-primary text-white border-left border-right'>Date</a></th>
                <th class='bg-primary text-white d-none d-lg-block'>Venue</th>
                <th class='bg-primary text-white'>Comp</th>
                <th class='bg-primary text-white border-left border-right d-none d-lg-block'>M/F</th>
                <th class='col-2 bg-primary text-white border-left border-right'>Home Team</th>
                <th colspan='2' class='col-1 bg-primary text-white border-left border-right text-center'>Score</th>
                <th class='col-2 bg-primary text-white border-left border-right'>Away Team</th>
                <th class='bg-primary text-white border-left border-right d-none d-md-block'>Referee</th>
                <th class='bg-primary text-white border-left border-right text-center'>Edit</th>
                <th class='bg-primary text-white border-left border-right text-center'>Delete</th>
            </tr>
        </thead>
        <tbody>
<?php
  if($result = mysqli_query($link,$sql)) {
      while ($row = mysqli_fetch_array($result)) {
          echo "
                      <tr>
                          <td class='border-left border-right d-none d-xl-block'>{$row[6]}</td> <!-- ID -->
                          <td class='border-left border-right'><a href='viewMatch.php?matchID={$row[6]}'>{$row[0]}</a></td><!-- Date -->
                          <td class='text-left border-left border-right d-none d-lg-block'>{$row[1]}</td><!-- Venue -->
                          <td class='border-left border-right'>{$row[2]}</td><!-- Comp -->
                          <td class='border-left border-right d-none d-lg-block' style='text-align:center'>{$row[7]}</td><!-- Gender -->
                          <td class='border-left border-right'>{$row[3]}</td><!-- Home Team -->
                          <td class='border-left border-right' style='text-align:center'>{$row[8]}</td><!-- Home Score -->
                          <td class='border-left border-right' style='text-align:center'>{$row[9]}</td><!-- Away Score -->
                          <td class='border-left border-right'>{$row[4]}</td><!-- Away Team -->
                          <td class='border-left border-right d-none d-md-block'>{$row[5]}</td><!-- Referee -->";
          if($role >= 5) {
              echo "
                          <td class='border-left border-right text-center'>
                              <form action='../edit/updateMatch.php' method='POST' onsubmit=''/>
                                  <input type='hidden' name='q' value='".$row[6]."'/><button class='btn btn-primary' type='Submit' value='Update'><i class='fa fa-edit'></i></button>
                              </form>
                          </td>";
          }
          if($role > 5) {
              echo "
                          <td style='text-align:center'>
                              <form action='../delete/deleteMatch.php' method='POST' onsubmit='' onclick='return confirm(`do you want to delete {$row[3]} vs {$row[4]} on the {$row[0]}`)'/><input type='hidden' name='q' value='".$row[6]."' /><button class='btn btn-danger' type='Submit' value='Delete'><i class='fa fa-trash'></i></button>
                              </form>
                          </td>";
          }
          echo "
                      </tr>";
      }    
      echo "
                  </tbody>
              </table>
          </div>
  </div>";

我的表头有问题

标签: cssbootstrap-4

解决方案


问题在于-block类中的后缀。你应该-table-cell改用。

在文档中查看更多信息

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
  <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script>
</head>
<body>
<div class='container mx-auto' style='width: 100%'>
    <table class='table table-hover' style='width: 100%'>
        <thead class='bg-primary text-white'>  
            <tr>
                <th class='bg-primary text-white border-left border-right d-none d-xl-table-cell'>ID</th>
                <th class='col-2 bg-primary text-white border-left border-right'>Date</a></th>
                <th class='bg-primary text-white d-none d-lg-table-cell'>Venue</th>
                <th class='bg-primary text-white'>Comp</th>
                <th class='bg-primary text-white border-left border-right d-none d-lg-table-cell'>M/F</th>
                <th class='col-2 bg-primary text-white border-left border-right'>Home Team</th>
                <th colspan='2' class='col-1 bg-primary text-white border-left border-right text-center'>Score</th>
                <th class='col-2 bg-primary text-white border-left border-right'>Away Team</th>
                <th class='bg-primary text-white border-left border-right d-none d-md-table-cell'>Referee</th>
                <th class='bg-primary text-white border-left border-right text-center'>Edit</th>
                <th class='bg-primary text-white border-left border-right text-center'>Delete</th>
            </tr>
        </thead>
        <tbody>
        </tbody>
    </table>
</div>
</body>
</html>


推荐阅读