css ヘッダー固定

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了css ヘッダー固定相关的知识,希望对你有一定的参考价值。

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
  <title>Bootstrap 101 Template</title>
  <!-- Latest compiled and minified CSS -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  <!-- Optional theme -->
  <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

  <link rel="stylesheet" href="main.css">

  <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  <![endif]-->
</head>
<body>
<div class="container">
  <div class="row">
    <div class="col col-sm-8 col-md-8">
      <table class="table table-striped table-hover table-condensed table-header-fixed">
        <thead>
          <tr>
            <th>#</th>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Username</th>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>1</td>
            <td>Mark</td>
            <td>Otto</td>
            <td>@mdo</td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>
</div>
  <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
  <!-- Latest compiled and minified JavaScript -->
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

</body>
</html>
table.table-header-fixed {
/*    width: 100%;*/
}

table.table-header-fixed thead,
table.table-header-fixed tbody,
table.table-header-fixed tr,
table.table-header-fixed td,
table.table-header-fixed th {
    display: block;
}

table.table-header-fixed tr:after {
    content: ' ';
    display: block;
    visibility: hidden;
    clear: both;
}

table.table-header-fixed tbody {
    height: 190px;
    overflow-y: scroll;
}

table.table-header-fixed thead {
    /* fallback */
    width: 97%;
    /* minus scroll bar width */
    width: calc(100% - 17px);
}

table.table-header-fixed tbody td,
table.table-header-fixed thead th {
    float: left;
    height: 38px;
}

以上是关于css ヘッダー固定的主要内容,如果未能解决你的问题,请参考以下文章

css 子テーマのスタイルシートヘッダーサンプル

css スマホヘッダー下シャドウ

javascript ページ内リンク时固定ヘッダーをかぶらないようにする

css Flexboxで両端ぞろえヘッダーやfooterに活跃する!!

text フッターメニュー。ヘッダーメニュー

python pandas二行ヘッダー