{"id":16922,"date":"2025-01-31T14:05:45","date_gmt":"2025-01-31T05:05:45","guid":{"rendered":"https:\/\/nxpg.net\/blog\/tech\/?p=16922"},"modified":"2025-03-03T16:34:18","modified_gmt":"2025-03-03T07:34:18","slug":"css%e3%81%aehas%e3%82%bb%e3%83%ac%e3%82%af%e3%82%bf%e3%82%92%e4%bd%bf%e3%81%8a%e3%81%86%ef%bc%81","status":"publish","type":"post","link":"https:\/\/nxpg.net\/blog\/tech\/?p=16922","title":{"rendered":"CSS\u306e:has()\u30bb\u30ec\u30af\u30bf\u3092\u4f7f\u304a\u3046\uff01"},"content":{"rendered":"\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" loading=\"lazy\" width=\"960\" height=\"540\" src=\"https:\/\/nxpg.net\/blog\/tech\/wp-content\/uploads\/sites\/7\/thumbnail_16922.png\" alt=\"\" class=\"wp-image-16956\" srcset=\"https:\/\/nxpg.net\/blog\/tech\/wp-content\/uploads\/sites\/7\/thumbnail_16922.png 960w, https:\/\/nxpg.net\/blog\/tech\/wp-content\/uploads\/sites\/7\/thumbnail_16922-624x351.png 624w\" sizes=\"(max-width: 960px) 100vw, 960px\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<p>\u7686\u3055\u3093\u3053\u3093\u306b\u3061\u306f\u3001\u30a2\u30f3\u30c9\u30ec\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u30b3\u30fc\u30c0\u30fc\u306e\u7686\u3055\u3093\u3001:has()\u3001\u4f7f\u3063\u3066\u307e\u3059\u304b\uff1f<\/p>\n\n\n\n<p>Firefox\u306e\u30b5\u30dd\u30fc\u30c8\u304c\u9045\u304b\u3063\u305f\uff082023\/12\/19\u306eVer.121\u304b\u3089\uff09\u305f\u3081\u3001\u6628\u5e74\u306e\u7279\u306b\u5e8f\u76e4\u306a\u3069\u306f\u3042\u308b\u7a0b\u5ea6\u69d8\u5b50\u3092\u898b\u306a\u304c\u3089\u4f7f\u3063\u3066\u3044\u305f\u306e\u3067\u3059\u304c\u3001\u3055\u3059\u304c\u306b\u3082\u3046\u5927\u4e08\u592b\u3060\u308d\u3046\u3068\u3044\u3046\u3053\u3068\u3067\u3001\u8a18\u4e8b\u306b\u3059\u3079\u304f\u7b46\u3092\u57f7\u308a\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u3055\u3066\u3001\u4e00\u4f53:has()\u306e\u4f55\u304c\u3059\u3054\u3044\u306e\u304b\u3001\u306b\u3064\u3044\u3066\u3067\u3059\u304c\u3001\u7aef\u7684\u306b\u8a00\u3048\u3070\u3001<\/p>\n\n\n\n<p><strong>\u4eca\u307e\u3067\uff08CSS\u3060\u3051\u3067\u306f\uff09\u3067\u304d\u306a\u304b\u3063\u305f\u3053\u3068\u304c\u3067\u304d\u308b<\/strong><\/p>\n\n\n\n<p>\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305a\u3001\u5144\u5f1f\u306e\u95a2\u4fc2\u306b\u304a\u3044\u3066\u3001<br>\u4f8b\u3048\u3070\u3001\u7279\u5b9a\u306e\u8981\u7d20\uff08A\u3068\u3057\u307e\u3059\uff09\u3092\u524d\u306b\u6301\u3064\u8981\u7d20\uff08B\u3068\u3057\u307e\u3059\uff09\u3067\u3042\u308c\u3070\u3001<a href=\"https:\/\/developer.mozilla.org\/ja\/docs\/Web\/CSS\/Next-sibling_combinator\" target=\"_blank\" rel=\"noopener nofollow\" title=\"\">\u6b21\u5144\u5f1f\u7d50\u5408\u5b50<\/a>\u3092\u7528\u3044\u308c\u3070<\/p>\n\n\n\n<p><strong>A + B {<\/strong><\/p>\n\n\n\n<p>\u3068\u3044\u3046\u5f62\u3067\u30b9\u30bf\u30a4\u30eb\u3092\u5236\u5fa1\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3057\u305f\u304c\u3001\u305d\u306e\u9006\u306e\u3001\u7279\u5b9a\u306e\u8981\u7d20\uff08B\uff09\u3092\u5f8c\u306b\u6301\u3064\u8981\u7d20\uff08A\uff09\u3092\u6307\u5b9a\u3059\u308b\u8853\u306f\u3042\u308a\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u305d\u308c\u304c:has()\u3092\u4f7f\u3048\u3070\u3001<\/p>\n\n\n\n<p><strong>A:has(+ B) {<\/strong><\/p>\n\n\n\n<p>\u3068\u3044\u3046\u5f62\u3067\u6307\u5b9a\u3067\u304d\u3001\u3055\u3089\u306bB\u306b\u7279\u5b9a\u306e\u8981\u7d20\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u304b\u3001\u306a\u3069\u3082\u6761\u4ef6\u3068\u3059\u308b\u3053\u3068\u304c\u53ef\u80fd\u3068\u306a\u308a\u307e\u3059\u3002<br>\u4f8b\u3048\u3070\u5f8c\u7d9a\u306eB\u306bC\u304c\u542b\u307e\u308c\u3066\u3044\u308b\u5834\u5408\u3001\u3068\u3057\u305f\u304b\u3063\u305f\u3089\u3001<\/p>\n\n\n\n<p><strong>A:has(+ B C) {<\/strong><\/p>\n\n\n\n<p>\u3068\u3059\u308c\u3070OK\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u307e\u305f\u3001\u89aa\u5b50\u306e\u95a2\u4fc2\u306b\u304a\u3044\u3066\u306f\u3001<br>\u7279\u5b9a\u306e\u89aa\u3092\u6301\u3064\u304b\uff08\uff1d\u30b3\u30f3\u30c6\u30ad\u30b9\u30c8\uff09\u306b\u3088\u308b\u5b50\u8981\u7d20\u306e\u30b9\u30bf\u30a4\u30eb\u5236\u5fa1\u306f\u3067\u304d\u307e\u3057\u305f\u304c\u3001\u305d\u306e\u9006\u306e\u3001\u7279\u5b9a\u306e\u5b50\u8981\u7d20\u3092\u6301\u3064\u89aa\u8981\u7d20\u306b\u5bfe\u3057\u3066\u30b9\u30bf\u30a4\u30eb\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u306f\u3067\u304d\u307e\u305b\u3093\u3067\u3057\u305f\u3002<br>\u3067\u3059\u306e\u3067\u3001\u4f8b\u3048\u3070\u30d5\u30a9\u30fc\u30e0\u5185\u306b\u30a8\u30e9\u30fc\u6587\u8a00\uff08.error\u3068\u3057\u307e\u3059\uff09\u304c\u3042\u3063\u305f\u3089\u30d5\u30a9\u30fc\u30e0\u306e\u80cc\u666f\u8272\u3092\u8d64\u8272\u306b\u3057\u305f\u3044\u3001\u3068\u3044\u3046\u5834\u5408\u306f\u3001JS\u3067.error\u306e\u6709\u7121\u3092\u8abf\u3079\u3001\u3042\u3063\u305f\u3089\u30d5\u30a9\u30fc\u30e0\u306b.has_error\u306e\u3088\u3046\u306aclass\u3092\u8ffd\u52a0\uff08\u3057\u3066\u80cc\u666f\u8272\u3092\u5909\u66f4\uff09\u3057\u305f\u308a\u3057\u3066\u3044\u307e\u3057\u305f\u3002<\/p>\n\n\n\n<p>\u305d\u308c\u304c:has()\u3092\u4f7f\u3048\u3070\u3001<\/p>\n\n\n\n<p><strong>form:has(.error) {<\/strong><\/p>\n\n\n\n<p>\u3068\u8a18\u8ff0\u3059\u308b\u3060\u3051\u3067OK\u306a\u306e\u3067\u3059\u3002\u4fbf\u5229\u3067\u3057\u3087\u3046\uff1f<\/p>\n\n\n\n<p>\u3053\u3053\u304b\u3089\u306f\u3001\u79c1\u304c\u3053\u308c\u306f\u4fbf\u5229\u3060\uff01\u3000\u3068\u611f\u3058\u305f\u30b1\u30fc\u30b9\u30922\u3064\u307b\u3069\u3054\u7d39\u4ecb\u3057\u305f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30b9\u30e9\u30a4\u30c9\uff08\u30ab\u30eb\u30fc\u30bb\u30eb\uff09\u306e\u9805\u76ee\u304c1\u3064\u3057\u304b\u306a\u3044\u3068\u304d\u306b\u9032\u3081\u308b\uff0f\u623b\u308b\u30dc\u30bf\u30f3\u3092\u975e\u8868\u793a<\/h2>\n\n\n\n<p class=\"codepen\" data-height=\"300\" data-default-tab=\"css,result\" data-slug-hash=\"XJrOejq\" data-pen-title=\"\u30b9\u30e9\u30a4\u30c9\uff08\u30ab\u30eb\u30fc\u30bb\u30eb\uff09\u306e\u9805\u76ee\u304c1\u3064\u3057\u304b\u306a\u3044\u3068\u304d\u306b\u9032\u3081\u308b\uff0f\u623b\u308b\u30dc\u30bf\u30f3\u3092\u975e\u8868\u793a\u306e\u30b5\u30f3\u30d7\u30eb\" data-user=\"NP-okada\" style=\"height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\">\n  <span>See the Pen <a href=\"https:\/\/codepen.io\/NP-okada\/pen\/XJrOejq\">\n  \u30b9\u30e9\u30a4\u30c9\uff08\u30ab\u30eb\u30fc\u30bb\u30eb\uff09\u306e\u9805\u76ee\u304c1\u3064\u3057\u304b\u306a\u3044\u3068\u304d\u306b\u9032\u3081\u308b\uff0f\u623b\u308b\u30dc\u30bf\u30f3\u3092\u975e\u8868\u793a\u306e\u30b5\u30f3\u30d7\u30eb<\/a> by Takamasa Okada (<a href=\"https:\/\/codepen.io\/NP-okada\">@NP-okada<\/a>)\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/span>\n<\/p>\n<script async src=\"https:\/\/public.codepenassets.com\/embed\/index.js\"><\/script>\n\n\n\n<p>\u30b9\u30e9\u30a4\u30c9\u9805\u76ee\uff08.splide__slide\uff09\u304c1\u3064\u3060\u3051\uff08:only-child\uff09\u306e\u30b9\u30e9\u30a4\u30c9\uff08.splide\uff09\u306e\u30ca\u30d3\u30b2\u30fc\u30b7\u30e7\u30f3\uff08.splide__arrows\uff09\u3092\u975e\u8868\u793a\u306b\u3001\u3068\u3044\u3046\u6307\u5b9a\u306e\u4ed5\u65b9\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u30e1\u30cb\u30e5\u30fc\u30dc\u30bf\u30f3\u306e\u72b6\u614b\u5909\u66f4\u3060\u3051\u3067\u30e1\u30cb\u30e5\u30fc\u3068\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3082\u5236\u5fa1\u3059\u308b<\/h2>\n\n\n\n<p class=\"codepen\" data-height=\"300\" data-default-tab=\"css,result\" data-slug-hash=\"pvzGWZa\" data-pen-title=\"\u30e1\u30cb\u30e5\u30fc\u30dc\u30bf\u30f3\u306e\u72b6\u614b\u5909\u66f4\u3060\u3051\u3067\u30e1\u30cb\u30e5\u30fc\u3068\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3082\u5236\u5fa1\u3059\u308b\u30b5\u30f3\u30d7\u30eb\" data-user=\"NP-okada\" style=\"height: 300px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;\">\n  <span>See the Pen <a href=\"https:\/\/codepen.io\/NP-okada\/pen\/pvzGWZa\">\n  \u30e1\u30cb\u30e5\u30fc\u30dc\u30bf\u30f3\u306e\u72b6\u614b\u5909\u66f4\u3060\u3051\u3067\u30e1\u30cb\u30e5\u30fc\u3068\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u3082\u5236\u5fa1\u3059\u308b\u30b5\u30f3\u30d7\u30eb<\/a> by Takamasa Okada (<a href=\"https:\/\/codepen.io\/NP-okada\">@NP-okada<\/a>)\n  on <a href=\"https:\/\/codepen.io\">CodePen<\/a>.<\/span>\n<\/p>\n\n\n\n<p>\u30e1\u30cb\u30e5\u30fc\u30dc\u30bf\u30f3\u306e\u72b6\u614b\uff08aria-expanded\uff09\u306e\u5909\u66f4\u3060\u3051\u3067\u3001\u53f3\u304b\u3089\u30e1\u30cb\u30e5\u30fc\u3092\u30b9\u30e9\u30a4\u30c9\u8868\u793a\uff06\u30aa\u30fc\u30d0\u30fc\u30ec\u30a4\u306e\u8868\u793a\u3092\u3055\u305b\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><strong>:has(.menuBtn[aria-expanded=true])<\/strong><\/p>\n\n\n\n<p>\u3068\u3044\u3046\u5f62\u3067\u76f4\u63a5\u95a2\u4fc2\u306e\u306a\u3044.menuBtn\u306e\u72b6\u614b\u3092\u62fe\u3063\u3066\u304d\u3066\u3044\u308b\u306e\u304c\u30df\u30bd\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u3000<\/p>\n\n\n\n<p>:has()\u306e\u3059\u3054\u3055\u3001\u4f1d\u308f\u308a\u307e\u3057\u305f\u3067\u3057\u3087\u3046\u304b\uff1f<br>\u305c\u3072\u6d3b\u7528\u3057\u3066\u3001\u30b7\u30f3\u30d7\u30eb\u304b\u3064\u30b9\u30de\u30fc\u30c8\u306a\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u306e\u5b9f\u73fe\u306b\u5f79\u7acb\u3066\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u305d\u308c\u3067\u306f\u3001\u307e\u305f\u3002<\/p>\n\n\n\n<p>\u3000<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u7686\u3055\u3093\u3053\u3093\u306b\u3061\u306f\u3001\u30a2\u30f3\u30c9\u30ec\u3067\u3059\u3002 \u30b3\u30fc\u30c0\u30fc\u306e\u7686\u3055\u3093\u3001:has()\u3001\u4f7f\u3063\u3066\u307e\u3059\u304b\uff1f Firefox\u306e\u30b5\u30dd\u30fc\u30c8\u304c\u9045\u304b\u3063\u305f\uff082023\/12\/19\u306eVer.121\u304b\u3089\uff09\u305f\u3081\u3001\u6628\u5e74\u306e\u7279\u306b\u5e8f\u76e4\u306a\u3069\u306f\u3042\u308b\u7a0b\u5ea6\u69d8\u5b50\u3092\u898b\u306a\u304c\u3089\u4f7f\u3063\u3066\u3044\u305f\u306e [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":16956,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[6,10],"tags":[],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/posts\/16922"}],"collection":[{"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16922"}],"version-history":[{"count":2,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/posts\/16922\/revisions"}],"predecessor-version":[{"id":16959,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/posts\/16922\/revisions\/16959"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=\/wp\/v2\/media\/16956"}],"wp:attachment":[{"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16922"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16922"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nxpg.net\/blog\/tech\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16922"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}