6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Chromeで印刷時にtheadを各ページに出力

Last updated at Posted at 2019-10-29
thead {
  display: table-header-group;
  break-inside: avoid;
}

参考: Repeating table headers in PDF downloads using headless chrome | berliners blog

theadにdisplay: table-header-groupを指定すると、印刷時にページごとにtheadの内容を出力できます。これははっきり仕様にあるわけではなく、ブラウザーの慣習らしいです。Chromeはこれに対応していませんでしたが、わりと最近、display: table-header-groupに加えてbreak-inside: avoidがあれば、ほかのブラウザーのように動作するよう修正されたそうです。

CSS 2.1の仕様には次の文があります。may とされています。

Print user agents may repeat header rows on each page spanned by a table.

HTML5CSS3にはtheadの印刷に関する記述は見当たりませんでした。

6
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?