{"id":26324,"date":"2024-11-24T11:39:43","date_gmt":"2024-11-24T03:39:43","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26324\/"},"modified":"2024-11-24T11:39:43","modified_gmt":"2024-11-24T03:39:43","slug":"%e9%9a%90%e8%97%8f%e5%85%83%e7%b4%a0-css-%e6%8c%91%e6%88%98-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26324\/","title":{"rendered":"\u9690\u85cf\u5143\u7d20 &#8211; CSS \u6311\u6218"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173088589298850.jpg\" class=\"aligncenter\" title=\"\u9690\u85cf\u5143\u7d20 &#8211; CSS \u6311\u6218\u63d2\u56fe\" alt=\"\u9690\u85cf\u5143\u7d20 &#8211; CSS \u6311\u6218\u63d2\u56fe\" \/><\/p>\n<p>\u60a8\u53ef\u4ee5\u5728 hub \u4ed3\u5e93\u4e2d\u627e\u5230\u8fd9\u7bc7\u6587\u7ae0\u4e2d\u7684\u6240\u6709\u4ee3\u7801\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u5728\u6b64\u5904\u67e5\u770b\u9690\u85cf\u5143\u7d20\u7684\u89c6\u89c9\u6548\u679c &#8211; codesandbox<\/p>\n<hr>\n<h3> \u9690\u85cf\u5143\u7d20 <\/h3>\n<pre>&lt;!doctype html&gt;\n&lt;html lang=\"en\"&gt;\n  &lt;head&gt;\n    &lt;meta charset=\"utf-8\" \/&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\" \/&gt;\n    &lt;meta http-equiv=\"x-ua-compatible\" content=\"ie=edge\" \/&gt;\n    &lt;title&gt;hiding elements&lt;\/title&gt;\n    &lt;link rel=\"stylesheet\" href=\"styles.css\" \/&gt;\n  &lt;\/head&gt;\n  &lt;body&gt;\n    &lt;div class=\"display-none\"&gt;hiding elements&lt;\/div&gt;\n\n    &lt;div id=\"hidden\" hidden&gt;hiding elements&lt;\/div&gt;\n\n    &lt;div class=\"outside-by-absolute\"&gt;hiding elements&lt;\/div&gt;\n\n    &lt;div class=\"outside-by-relative\"&gt;hiding elements&lt;\/div&gt;\n\n    &lt;div class=\"outside-by-margin\"&gt;hiding elements&lt;\/div&gt;\n\n    &lt;div aria-hidden=\"true\"&gt;hiding elements(for screen reader)&lt;\/div&gt;\n\n    &lt;div class=\"hide-by-opacacity\"&gt;hiding elements&lt;\/div&gt;\n\n    &lt;div class=\"container\"&gt;\n      &lt;div class=\"hidden-element\"&gt;this is hidden&lt;\/div&gt;\n      &lt;div class=\"covering-element\"&gt;covering the elements&lt;\/div&gt;\n    &lt;\/div&gt;\n\n    &lt;div class=\"hide-by-clip\"&gt;hiding elements&lt;\/div&gt;\n\n    &lt;div class=\"hide-by-transform\"&gt;hiding elements&lt;\/div&gt;\n  &lt;\/body&gt;\n&lt;\/html&gt;\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.display-none {\n  display: none;\n}\n\n.outside-by-absolute {\n  position: absolute;\n  left: -9999px;\n}\n\n.outside-by-relative {\n  position: relative;\n  left: -9999px;\n}\n\n.outside-by-margin {\n  margin-left: -9999px;\n}\n\n.hide-by-opacacity {\n  opacity: 0;\n}\n\n.container {\n  position: relative;\n  width: 200px;\n  height: 200px;\n}\n\n.covering-element {\n  position: absolute;\n  width: 100%;\n  height: 100%;\n  z-index: 2;\n}\n\n.hidden-element {\n  position: absolute;\n  width: 100%;\n  height: 100%;\n  z-index: 1;\n}\n\n.hide-by-clip {\n  position: absolute;\n  width: 200px;\n  height: 200px;\n  clip: rect(0px, 0px, 0px, 0px);\n}\n\n.hide-by-transform {\n  transform: scale(0, 0);\n}\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u9690\u85cf\u5143\u7d20 &#8211; CSS \u6311\u6218\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u60a8\u53ef\u4ee5\u5728 hub \u4ed3\u5e93\u4e2d\u627e\u5230\u8fd9\u7bc7\u6587\u7ae0\u4e2d\u7684\u6240\u6709\u4ee3\u7801\u3002 \u60a8\u53ef\u4ee5\u5728\u6b64\u5904\u67e5\u770b\u9690\u85cf\u5143\u7d20\u7684\u89c6\u89c9\u6548\u679c &#8211; codesandbox \u9690\u85cf\u5143\u7d20 &lt;!doctype html&gt; &lt;html lang=&#8221;en&#8221;&gt; &lt;head&gt; &lt;meta charset=&#8221;utf-8&#8243; \/&gt; &lt;meta name=&#8221;viewport&#8221; content=&#8221;width=device-width, initial-scale=1.0&#8243; \/&gt; &lt;meta http-equiv=&#8221;x-ua-compatible&#8221; content=&#8221;ie=edge&#8221; \/&gt; &lt;title&gt;hiding elements&lt;\/title&gt; &lt;link rel=&#8221;stylesheet&#8221; href=&#8221;styles.css&#8221; \/&gt; &lt;\/head&gt; &lt;body&gt; &lt;div class=&#8221;display-none&#8221;&gt;hiding elements&lt;\/div&gt; &lt;div id=&#8221;hidden&#8221; hidden&gt;hiding elements&lt;\/div&gt; &lt;div class=&#8221;outside-by-absolute&#8221;&gt;hiding elements&lt;\/div&gt; &lt;div class=&#8221;outside-by-relative&#8221;&gt;hiding elements&lt;\/div&gt; &lt;div class=&#8221;outside-by-margin&#8221;&gt;hiding elements&lt;\/div&gt; &lt;div aria-hidden=&#8221;true&#8221;&gt;hiding elements(for screen reader)&lt;\/div&gt; &lt;div class=&#8221;hide-by-opacacity&#8221;&gt;hiding [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-26324","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26324","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=26324"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26324\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26324"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26324"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26324"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}