

{"id":1478,"date":"2020-07-04T11:56:22","date_gmt":"2020-07-04T02:56:22","guid":{"rendered":"https:\/\/curecode.jp\/tech\/?p=1478"},"modified":"2020-07-04T12:10:37","modified_gmt":"2020-07-04T03:10:37","slug":"css-table-position-sticky-with-background-border-vanished","status":"publish","type":"post","link":"https:\/\/curecode.jp\/tech\/css-table-position-sticky-with-background-border-vanished\/","title":{"rendered":"[CSS] table \u306e\u5217\u56fa\u5b9a\u306b position: sticky \u3092\u4f7f\u7528\u3057\u3066\u80cc\u666f\u8272\u3092\u6307\u5b9a\u3059\u308b\u3068\u3001\u67a0\u7dda\u304c\u6d88\u3048\u3066\u3057\u307e\u3046"},"content":{"rendered":"<p>\n \u6a2a\u30b9\u30af\u30ed\u30fc\u30eb\u3059\u308b\u30c6\u30fc\u30d6\u30eb\u306b\u3064\u3044\u3066\u306e\u8a71\u3067\u3059\u3002\n<\/p>\n<style>\n.table-parent {width:80%;max-width:540px;overflow-x:scroll;margin:1em auto;border:1px solid silver;}\n.table-sample { border: 1px solid silver; border-collapse:collapse; color:black; background-color:white; }\n.table-sample th, .table-sample td {border: 1px solid silver; padding:4px; white-space:nowrap;}\n.table-sample th {background-color:lightblue;}\n.table-fixed th:first-child, .table-fixed td:first-child {position: sticky; left:0;}\n.table-fixed2 td:first-child {background-color:white;}\n.table-fixed3 th:first-child {background-color:lightblue; background-clip:padding-box;}\n.table-fixed3 td:first-child {background-color:white; background-clip:padding-box;}\n {background-clip:padding-box;}\n<\/style>\n<h3>\u6a2a\u30b9\u30af\u30ed\u30fc\u30eb\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u4f8b<\/h3>\n<div class=\"table-parent\">\n<table class=\"table-sample\">\n<thead>\n<tr>\n<th>\u540d\u524d<\/th>\n<th>\u756a\u53f7<\/th>\n<th>\u30c7\u30fc\u30bf1<\/th>\n<th>\u30c7\u30fc\u30bf2<\/th>\n<th>\u30c7\u30fc\u30bf2<\/th>\n<th>\u30c7\u30fc\u30bf4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u5bcc\u5c71\u3000\u4e00\u90ce<\/td>\n<td>A01234567<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<tr>\n<td>\u77f3\u5ddd\u3000\u82b1\u5b50<\/td>\n<td>ZX0000000<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<tr>\n<td>\u798f\u4e95\u3000\u30bf\u30ab\u30b7<\/td>\n<td>QQQ9999999<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<h3>\u5217\u3092\u56fa\u5b9a\u3059\u308b<\/h3>\n<p>\n\u5217\u3092\u56fa\u5b9a\u3059\u308b\u305f\u3081\u306b\u3001css \u3067 <code>position: sticky;<\/code> \u3092\u4f7f\u3046\u65b9\u6cd5\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u306e\u3068\u304d\u306f <code>left: 0;<\/code> \u3082\u4e00\u7dd2\u306b\u6307\u5b9a\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002\n<\/p>\n<pre><code class=\"css\">\r\n.table-fixed th:first-child, .table-fixed td:first-child {\r\n  position: sticky; \r\n  left: 0;\r\n}\r\n<\/code><\/pre>\n<div class=\"table-parent\">\n<table class=\"table-sample table-fixed\">\n<thead>\n<tr>\n<th>\u540d\u524d<\/th>\n<th>\u756a\u53f7<\/th>\n<th>\u30c7\u30fc\u30bf1<\/th>\n<th>\u30c7\u30fc\u30bf2<\/th>\n<th>\u30c7\u30fc\u30bf2<\/th>\n<th>\u30c7\u30fc\u30bf4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u5bcc\u5c71\u3000\u4e00\u90ce<\/td>\n<td>A01234567<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<tr>\n<td>\u77f3\u5ddd\u3000\u82b1\u5b50<\/td>\n<td>ZX0000000<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<tr>\n<td>\u798f\u4e95\u3000\u30bf\u30ab\u30b7<\/td>\n<td>QQQ9999999<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\n  \u3057\u304b\u3057\u4e0a\u306e\u30c7\u30e2\u306e\u3088\u3046\u306b\u3001\u56fa\u5b9a\u3057\u305f\u5217\u306e\u80cc\u666f\u304c\u900f\u3051\u3066\u3057\u307e\u3044\u307e\u3059\u3002\u6a2a\u30b9\u30af\u30ed\u30fc\u30eb\u3059\u308b\u3068\u6587\u5b57\u304c\u91cd\u306a\u3063\u3066\u3057\u307e\u3044\u307e\u3059\u3002\n<\/p>\n<h3>\u80cc\u666f\u8272\u3092\u6307\u5b9a<\/h3>\n<p>\n  \u305d\u3053\u3067\u3001td \u8981\u7d20\u306b\u80cc\u666f\u3092\u6307\u5b9a\u3057\u3066\u307f\u307e\u3059\u3002\n<\/p>\n<pre><code class=\"css\">\r\n.table-sample td {\r\n  background-color: white;\r\n}\r\n<\/code><\/pre>\n<div class=\"table-parent\">\n<table class=\"table-sample table-fixed table-fixed2\">\n<thead>\n<tr>\n<th>\u540d\u524d<\/th>\n<th>\u756a\u53f7<\/th>\n<th>\u30c7\u30fc\u30bf1<\/th>\n<th>\u30c7\u30fc\u30bf2<\/th>\n<th>\u30c7\u30fc\u30bf2<\/th>\n<th>\u30c7\u30fc\u30bf4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u5bcc\u5c71\u3000\u4e00\u90ce<\/td>\n<td>A01234567<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<tr>\n<td>\u77f3\u5ddd\u3000\u82b1\u5b50<\/td>\n<td>ZX0000000<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<tr>\n<td>\u798f\u4e95\u3000\u30bf\u30ab\u30b7<\/td>\n<td>QQQ9999999<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\n  \u3059\u308b\u3068\u3001\u80cc\u666f\u306f\u900f\u3051\u306a\u304f\u306a\u3063\u305f\u306e\u3067\u6587\u5b57\u306f\u91cd\u306a\u3089\u306a\u304f\u306a\u308a\u307e\u3057\u305f\u304c\u3001\u4eca\u5ea6\u306f\u67a0\u7dda\u304c\u6d88\u3048\u3066\u3057\u307e\u3044\u307e\u3057\u305f\u3002\u30d6\u30e9\u30a6\u30b6\u306b\u3088\u3063\u3066\u306f\u8868\u793a\u3055\u308c\u307e\u3059\u304c\u3001Firefox \u3067\u306f\u3053\u306e\u73fe\u8c61\u304c\u767a\u751f\u3057\u307e\u3059\u3002\n<\/p>\n<figure>\n<div id=\"attachment_1509\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1509\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2020\/07\/firefox-table-screenshot.png\" alt=\"Firefox \u3067\u898b\u305f\u3068\u304d\u306e table\" width=\"600\" height=\"189\" class=\"size-full wp-image-1509\" srcset=\"https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2020\/07\/firefox-table-screenshot.png 600w, https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2020\/07\/firefox-table-screenshot-300x95.png 300w, https:\/\/curecode.jp\/tech\/wp-content\/uploads\/2020\/07\/firefox-table-screenshot-200x63.png 200w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><p id=\"caption-attachment-1509\" class=\"wp-caption-text\">Firefox 77 \u3067\u8868\u793a\u3057\u305f\u3068\u304d\u306e\u30b9\u30af\u30ea\u30fc\u30f3\u30b7\u30e7\u30c3\u30c8\u3002\u56fa\u5b9a\u3057\u305f\u5217\u306e\u30dc\u30fc\u30c0\u30fc\u304c\u6d88\u3048\u3066\u3057\u307e\u3046<\/p><\/div><br \/>\n<\/figure>\n<p>\n  \u3053\u308c\u306f<code>border-collapse: collapse;<\/code> \u3092\u6307\u5b9a\u3057\u3066\u3044\u308b\u3068\u304d\u306b\u767a\u751f\u3057\u307e\u3059\u3002\u67a0\u7dda\u304c <code>collapse<\/code> \u3060\u3068\u30bb\u30eb\u306e\u67a0\u7dda\u306f\u7d71\u5408\u3055\u308c\u3066 table \u5074\u306b\u6240\u5c5e\u3059\u308b\u3053\u3068\u306b\u306a\u308a\u307e\u3059\u3002\u305d\u3057\u3066 <code>position: sticky; <\/code> \u3092\u6307\u5b9a\u3055\u308c\u305f\u8981\u7d20\uff081\u5217\u76ee\u306e\u30bb\u30eb\uff09\u306f table \u306e\u4e0a\u306b\u72ec\u7acb\u3057\u3066\u6d6e\u3044\u3066\u3044\u308b\u3088\u3046\u306a\u72b6\u614b\u306b\u306a\u308b\u305f\u3081\u3001\u30dc\u30fc\u30c0\u30fc\u304c\u898b\u3048\u306a\u304f\u306a\u3063\u3066\u3057\u307e\u3046\u306e\u3067\u3059\u3002\n<\/p>\n<h3>\u5bfe\u7b56<\/h3>\n<p>\n  \u7c21\u5358\u306a\u5bfe\u7b56\u65b9\u6cd5\u3068\u3057\u3066\u306f\u3001\u30bb\u30eb\u306e\u80cc\u666f\u8272\u3067\u5857\u308b\u7bc4\u56f2\u3092 <code>background-clip: padding-box;<\/code> \u3067\u5c0f\u3055\u304f\u3057\u3066\u3084\u308b\u3053\u3068\u3067\u3059\u3002\u901a\u5e38\u306f\u30dc\u30fc\u30c0\u30fc\u306e\u7bc4\u56f2\u307e\u3067\u5857\u3063\u3066\u3044\u307e\u3059\u304c\u3001\u30dc\u30fc\u30c0\u30fc\u306e\u5185\u5074\u3060\u3051\u3092\u5857\u308b\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002\n<\/p>\n<pre><code class=\"css\">\r\n.table-sample th {\r\n  background-color: lightblue;\r\n  background-clip: padding-box;\r\n}\r\n.table-sample td {\r\n  background-color: white;\r\n  background-clip: padding-box;\r\n}\r\n<\/code><\/pre>\n<div class=\"table-parent\">\n<table class=\"table-sample table-fixed table-fixed3\">\n<thead>\n<tr>\n<th>\u540d\u524d<\/th>\n<th>\u756a\u53f7<\/th>\n<th>\u30c7\u30fc\u30bf1<\/th>\n<th>\u30c7\u30fc\u30bf2<\/th>\n<th>\u30c7\u30fc\u30bf2<\/th>\n<th>\u30c7\u30fc\u30bf4<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>\u5bcc\u5c71\u3000\u4e00\u90ce<\/td>\n<td>A01234567<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<tr>\n<td>\u77f3\u5ddd\u3000\u82b1\u5b50<\/td>\n<td>ZX0000000<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<tr>\n<td>\u798f\u4e95\u3000\u30bf\u30ab\u30b7<\/td>\n<td>QQQ9999999<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<td>1234567890<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<p>\n  \u3053\u308c\u3067\u67a0\u7dda\u3082\u898b\u3048\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002 Bootstrap \u306e\u30c6\u30fc\u30d6\u30eb\u3067\u3082\u3053\u306e\u30c6\u30af\u30cb\u30c3\u30af\u306f\u6709\u52b9\u3067\u3059\u3002\n<\/p>\n<h3>IT\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u4e2d\uff01<\/h3>\n<p>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u682a\u5f0f\u4f1a\u793e\u306fIT\u30a8\u30f3\u30b8\u30cb\u30a2\u3092\u52df\u96c6\u3057\u3066\u304a\u308a\u307e\u3059\u3002\u5c11\u4eba\u6570\u306e\u8077\u5834\u306a\u306e\u3067\u3001\u4e0a\u6d41\u30fb\u4e0b\u6d41\u3084\u30b5\u30fc\u30d0\u30fc\u30fb\u30af\u30e9\u30a4\u30a2\u30f3\u30c8\u5bfe\u5fdc\u306e\u57a3\u6839\u306a\u304f\u3001\u3042\u306a\u305f\u306e\u5f37\u307f\u3092\u6d3b\u304b\u3057\u306a\u304c\u3089 \u3044\u308d\u3044\u308d\u306a\u3053\u3068\u306b\u30c1\u30e3\u30ec\u30f3\u30b8\u53ef\u80fd\u3067\u3059\u3002\u30a8\u30f3\u30b8\u30cb\u30a2\u3068\u3057\u3066\u306e\u672a\u7d4c\u9a13\u306e\u65b9\u3001\u7d4c\u9a13\u304c\u5c11\u306a\u3044\u65b9\u3082\u6b53\u8fce\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u4e0b\u8a18\u3088\u308aIT\u30a8\u30f3\u30b8\u30cb\u30a2\u52df\u96c6\u306e\u63a1\u7528\u60c5\u5831\u3092\u3054\u89a7\u3044\u305f\u3060\u3051\u307e\u3059\u3002<\/p>\n<div class=\"curecode_recruit_bn\">\n\t\t\t\t<a href=\"https:\/\/curecode.jp\/recruit\/itengineer\/\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/themes\/tech\/images\/it_recruit.png?20241220\" alt=\"\u4e8b\u696d\u62e1\u5927\u306b\u4f34\u3044\u65b0\u3057\u3044\u9818\u57df\u306b\u4e00\u7dd2\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u30e1\u30f3\u30d0\u30fc\u3092\u52df\u96c6\u3057\u307e\u3059\u3002\"  width=\"500\" height=\"180\"\/><br \/>\n\t\t\t\t<\/a>\n\t\t<\/div>\n<h3>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u516c\u5f0f\u30a4\u30f3\u30b9\u30bf\u30b0\u30e9\u30e0<\/h3>\n<p>\u30ad\u30e5\u30a2\u30b3\u30fc\u30c9\u682a\u5f0f\u4f1a\u793e\u306e\u65b0\u30b5\u30fc\u30d3\u30b9\u60c5\u5831\u3084\u3001\u30aa\u30d5\u30a3\u30b9\u30e9\u30a4\u30d5\u306e\u7d20\u6575\u306a\u77ac\u9593\u307e\u3067\u3002\u79c1\u305f\u3061\u306e\u65e5\u3005\u306e\u55b6\u307f\u3092\u3054\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n<div class=\"curecode_recruit_bn\">\n\t\t\t\t<a href=\"https:\/\/www.instagram.com\/curecode\/\" target=\"_blank\" rel=\"noopener noreferrer\"><br \/>\n\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/curecode.jp\/tech\/wp-content\/themes\/tech\/images\/insta_bn.png?20241220\" alt=\"\u4e8b\u696d\u62e1\u5927\u306b\u4f34\u3044\u65b0\u3057\u3044\u9818\u57df\u306b\u4e00\u7dd2\u306b\u53d6\u308a\u7d44\u3093\u3067\u3044\u304f\u30e1\u30f3\u30d0\u30fc\u3092\u52df\u96c6\u3057\u307e\u3059\u3002\"  width=\"500\" height=\"180\"\/><br \/>\n\t\t\t\t<\/a>\n\t\t<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u6a2a\u30b9\u30af\u30ed\u30fc\u30eb\u3059\u308b\u30c6\u30fc\u30d6\u30eb\u306b\u3064\u3044\u3066\u306e\u8a71\u3067\u3059\u3002 \u6a2a\u30b9\u30af\u30ed\u30fc\u30eb\u306e\u30c6\u30fc\u30d6\u30eb\u306e\u4f8b \u540d\u524d \u756a\u53f7 \u30c7\u30fc\u30bf1 \u30c7\u30fc\u30bf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1163,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[166],"tags":[163,165,164],"class_list":["post-1478","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css","tag-css","tag-table","tag-164"],"_links":{"self":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1478","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/comments?post=1478"}],"version-history":[{"count":32,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1478\/revisions"}],"predecessor-version":[{"id":1511,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/posts\/1478\/revisions\/1511"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/media\/1163"}],"wp:attachment":[{"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/media?parent=1478"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/categories?post=1478"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/curecode.jp\/tech\/wp-json\/wp\/v2\/tags?post=1478"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}