{"id":5380,"date":"2026-07-09T19:20:38","date_gmt":"2026-07-09T10:20:38","guid":{"rendered":"https:\/\/dennie.tokyo\/it\/?p=5380"},"modified":"2026-07-09T19:45:49","modified_gmt":"2026-07-09T10:45:49","slug":"z-index-%e3%81%ab%e3%81%a4%e3%81%84%e3%81%a6","status":"publish","type":"post","link":"https:\/\/dennie.tokyo\/it\/?p=5380","title":{"rendered":"z-index \u306b\u3064\u3044\u3066"},"content":{"rendered":"\n<p>z-index\u306f\u8981\u7d20\u304c\u91cd\u306a\u3063\u305f\u5834\u5408\u306b\u3069\u3061\u3089\u3092\u512a\u5148\u7684\u306b\u8868\u793a\u3059\u308b\u304b\u3092\u6307\u5b9a\u3059\u308b\u4e8b\u304c\u51fa\u6765\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u3059\u3002<\/p>\n\n\n\n<!--more-->\n\n\n\n<h1 class=\"wp-block-heading\">\u524d\u63d0<\/h1>\n\n\n\n<p>position \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u6307\u5b9a\u3059\u308b\u8981\u7d20\u306e\u5834\u5408\u3001\u6709\u52b9\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h1 class=\"wp-block-heading\">\u57fa\u672c<\/h1>\n\n\n\n<p>\u8981\u7d20\u3092\u4e0a\u4e0b\u5de6\u53f3\u4e2d\u592e\u5bc4\u305b\u306b\u3059\u308b\u5834\u5408\u3001position \u30d7\u30ed\u30d1\u30c6\u30a3\u3092\u4f7f\u7528\u3059\u308b\u4e8b\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>HTML<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-html\" data-lang=\"HTML\"><code>&lt;div class=&quot;sample&quot;&gt;&lt;\/div&gt;<\/code><\/pre><\/div>\n\n\n\n<p><strong>CSS<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-css\" data-lang=\"CSS\"><code>.sample {\n  position: relative;\n  width: 300px;\n  height: 300px;\n  background-color: #296971;\n}\n\n.sample::before {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  right: 0;\n  content: &#39;index-A&#39;;\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: #ffd700;\n}<\/code><\/pre><\/div>\n\n\n\n<p><strong>\u7d50\u679c<\/strong><\/p>\n\n\n\n<style>\n.sample_01 {\n  position: relative;\n  width: 300px;\n  height: 300px;\n  background-color: #296971;\n}\n.sample_01::before {\n  position: absolute;\n  top: 0;\n  bottom: 0;\n  left: 0;\n  right: 0;\n  content: 'index-A';\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: #ffd700;\n}\n<\/style>\n<div class=\"sample_01\"><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u78ba\u8a8d<\/h1>\n\n\n\n<h2 class=\"wp-block-heading\">\u8981\u7d20\u306e\u91cd\u306a\u308a<\/h2>\n\n\n\n<p>\u8981\u7d20\u3092\u91cd\u306d\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>HTML<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-html\" data-lang=\"HTML\"><code>&lt;div class=&quot;sample&quot;&gt;&lt;\/div&gt;<\/code><\/pre><\/div>\n\n\n\n<p><strong>CSS<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-css\" data-lang=\"CSS\"><code>.sample {\n  position: relative;\n  width: 300px;\n  height: 300px;\n  background-color: #296971;\n}\n\n.sample::before {\n  position: absolute;\n  top: 80px;\n  right: 80px;\n  content: &#39;index-A&#39;;\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: #ffd700;\n}\n\n.sample::after {\n  position: absolute;\n  bottom: 80px;\n  left: 80px;\n  content: &#39;index-B&#39;;\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: red;\n}\n<\/code><\/pre><\/div>\n\n\n\n<p><strong>\u7d50\u679c<\/strong><\/p>\n\n\n\n<p>after\u8981\u7d20(index-B)\u306e\u65b9\u304c\u512a\u5148\u7684\u306b\u8868\u793a\u3055\u308c\u308b\u4e8b\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<style>\n.sample_02 {\n  position: relative;\n  width: 300px;\n  height: 300px;\n  background-color: #296971;\n}\n.sample_02::before {\n  position: absolute;\n  top: 80px;\n  right: 80px;\n  content: 'index-A';\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: #ffd700;\n}\n.sample_02::after {\n  position: absolute;\n  bottom: 80px;\n  left: 80px;\n  content: 'index-B';\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: red;\n}\n<\/style>\n<div class=\"sample_02\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u8981\u7d20\u306e\u91cd\u306a\u308a\u306e\u9806\u5e8f\u6307\u5b9a<\/h2>\n\n\n\n<p>z-index\u3092\u6307\u5b9a\u3057\u3066\u3001\u91cd\u306a\u3063\u305f\u8981\u7d20\u306e\u8868\u793a\u9806\u4f4d\u3092\u5165\u308c\u66ff\u3048\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>HTML<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-html\" data-lang=\"HTML\"><code>&lt;div class=&quot;sample&quot;&gt;&lt;\/div&gt;<\/code><\/pre><\/div>\n\n\n\n<p><strong>CSS<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-css\" data-lang=\"CSS\"><code>.sample {\n  position: relative;\n  width: 300px;\n  height: 300px;\n  background-color: #296971;\n}\n\n.sample::before {\n  position: absolute;\n  top: 80px;\n  right: 80px;\n  content: &#39;index-A&#39;;\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: #ffd700;\n  z-index: 3;\n}\n\n.sample::after {\n  position: absolute;\n  bottom: 80px;\n  left: 80px;\n  content: &#39;index-B&#39;;\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: red;\n  z-index: 2;\n}\n<\/code><\/pre><\/div>\n\n\n\n<p><strong>\u7d50\u679c<\/strong><\/p>\n\n\n\n<p>before\u8981\u7d20(index-A)\u306e\u65b9\u304c\u512a\u5148\u7684\u306b\u8868\u793a\u3055\u308c\u308b\u4e8b\u304c\u5206\u304b\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<style>\n.sample_03 {\n  position: relative;\n  width: 300px;\n  height: 300px;\n  background-color: #296971;\n}\n.sample_03::before {\n  position: absolute;\n  top: 80px;\n  right: 80px;\n  content: 'index-A';\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: #ffd700;\n  z-index: 3;\n}\n.sample_03::after {\n  position: absolute;\n  bottom: 80px;\n  left: 80px;\n  content: 'index-B';\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: red;\n  z-index: 2;\n}\n<\/style>\n<div class=\"sample_03\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">\u89aa\u8981\u7d20\u3068\u306e\u9806\u4f4d<\/h2>\n\n\n\n<p>position: absolute \u3092\u6307\u5b9a\u3057\u305f\u5b50\u8981\u7d20\u306e z-index \u3092\u6307\u5b9a\u3057\u305f\u5834\u5408\u3001position: relative \u3092\u6307\u5b9a\u3057\u305f\u89aa\u8981\u7d20\u304c\u512a\u5148\u7684\u306b\u8868\u793a\u3055\u308c\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>HTML<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-html\" data-lang=\"HTML\"><code>&lt;div class=&quot;sample&quot;&gt;&lt;\/div&gt;<\/code><\/pre><\/div>\n\n\n\n<p><strong>CSS<\/strong><\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-css\" data-lang=\"CSS\"><code>.sample_04 {\n  position: relative;\n  width: 300px;\n  height: 300px;\n  background-color: #296971;\n}\n.sample::before {\n  position: absolute;\n  top: 80px;\n  right: 80px;\n  content: &#39;index-A&#39;;\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: #ffd700;\n  z-index: 1;\n}\n\n.sample::after {\n  position: absolute;\n  bottom: 80px;\n  left: 90%;\n  content: &#39;index-B&#39;;\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: red;\n  z-index: -1;\n}\n<\/code><\/pre><\/div>\n\n\n\n<p><strong>\u7d50\u679c<\/strong><\/p>\n\n\n\n<p>after\u8981\u7d20(index-B)\u306ez-index\u304c\u30de\u30a4\u30ca\u30b9\u306a\u306e\u3067\u89aa\u8981\u7d20\u306b\u96a0\u308c\u3066\u3057\u307e\u3046\u4e8b\u304c\u78ba\u8a8d\u51fa\u6765\u307e\u3059\u3002<\/p>\n\n\n\n<style>\n.sample_04 {\n  position: relative;\n  width: 300px;\n  height: 300px;\n  background-color: #296971;\n}\n.sample_04::before {\n  position: absolute;\n  top: 80px;\n  right: 80px;\n  content: 'index-A';\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: #ffd700;\n  z-index: 1;\n}\n.sample_04::after {\n  position: absolute;\n  bottom: 80px;\n  left: 90%;\n  content: 'index-B';\n  height: 100px;\n  width: 100px;\n  margin: auto;\n  background-color: red;\n  z-index: -1;\n}\n<\/style>\n<div class=\"sample_04\"><\/div>\n\n\n\n<h1 class=\"wp-block-heading\">\u6700\u5f8c\u306b<\/h1>\n\n\n\n<p>\u7279\u306b\u3042\u308a\u307e\u305b\u3093\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>z-index\u306f\u8981\u7d20\u304c\u91cd\u306a\u3063\u305f\u5834\u5408\u306b\u3069\u3061\u3089\u3092\u512a\u5148\u7684\u306b\u8868\u793a\u3059\u308b\u304b\u3092\u6307\u5b9a\u3059\u308b\u4e8b\u304c\u51fa\u6765\u308b\u30d7\u30ed\u30d1\u30c6\u30a3\u3067\u3059\u3002<\/p>\n","protected":false},"author":1,"featured_media":4723,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[],"class_list":["post-5380","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css"],"_links":{"self":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/5380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5380"}],"version-history":[{"count":10,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/5380\/revisions"}],"predecessor-version":[{"id":5390,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/posts\/5380\/revisions\/5390"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=\/wp\/v2\/media\/4723"}],"wp:attachment":[{"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dennie.tokyo\/it\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}