{"id":832,"date":"2025-12-20T16:07:52","date_gmt":"2025-12-20T08:07:52","guid":{"rendered":"https:\/\/www.52runoob.com\/?p=832"},"modified":"2025-12-20T16:07:52","modified_gmt":"2025-12-20T08:07:52","slug":"css%e5%ae%9e%e7%8e%b00-5px%ef%bc%88%e7%89%a9%e7%90%86%e5%83%8f%e7%b4%a0%ef%bc%89%e7%9a%84%e7%bb%86%e8%be%b9%e6%a1%86%e7%9a%845%e7%a7%8d%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.52runoob.com\/index.php\/2025\/12\/20\/css%e5%ae%9e%e7%8e%b00-5px%ef%bc%88%e7%89%a9%e7%90%86%e5%83%8f%e7%b4%a0%ef%bc%89%e7%9a%84%e7%bb%86%e8%be%b9%e6%a1%86%e7%9a%845%e7%a7%8d%e6%96%b9%e6%b3%95\/","title":{"rendered":"CSS\u5b9e\u73b00.5px\uff08\u7269\u7406\u50cf\u7d20\uff09\u7684\u7ec6\u8fb9\u6846\u76845\u79cd\u65b9\u6cd5"},"content":{"rendered":"\n<p>\u5728\u7f51\u9875\u8bbe\u8ba1\u4e2d\uff0c\u5f88\u591a\u65f6\u5019\u9700\u8981\u5b9e\u73b0\u975e\u5e38\u7ec6\u7684\u8fb9\u6846\uff0c\u6bd4\u5982 <strong>0.5px<\/strong> \u7684\u7ec6\u8fb9\u6846\u3002\u7136\u800c\uff0cCSS \u4e2d\u76f4\u63a5\u4f7f\u7528 <strong>0.5px<\/strong> \u7684\u8fb9\u6846\u53ef\u80fd\u5728\u67d0\u4e9b\u8bbe\u5907\u548c\u6d4f\u89c8\u5668\u4e0a\u663e\u793a\u4e0d\u6b63\u5e38\uff0c\u7279\u522b\u662f\u5728\u9ad8 DPI\uff08\u50cf\u7d20\u5bc6\u5ea6\uff09\u8bbe\u5907\u4e0a\u3002\u56e0\u4e3a\u5927\u90e8\u5206\u6d4f\u89c8\u5668\u4f1a\u5c06\u5c0f\u4e8e 1px \u7684\u8fb9\u6846\u6e32\u67d3\u6210 1px \u6216\u5b8c\u5168\u5ffd\u7565\u5b83\u3002\u4e0b\u9762\u5c06\u4ecb\u7ecd 5 \u79cd\u65b9\u6cd5\uff0c\u901a\u8fc7\u4e0d\u540c\u7684\u6280\u5de7\u6765\u5b9e\u73b0 <strong>0.5px<\/strong> \u7684\u7ec6\u8fb9\u6846\uff0c\u786e\u4fdd\u5728\u5404\u79cd\u8bbe\u5907\u4e0a\u90fd\u80fd\u6b63\u786e\u663e\u793a\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 1\uff1a\u4f7f\u7528 <code>transform<\/code> \u7ed3\u5408 <code>scale()<\/code><\/h2>\n\n\n\n<p>\u901a\u8fc7\u4f7f\u7528 <code>transform<\/code> \u7684 <code>scale()<\/code> \u65b9\u6cd5\uff0c\u53ef\u4ee5\u5bf9\u5143\u7d20\u8fdb\u884c\u7f29\u653e\uff0c\u4ece\u800c\u6709\u6548\u63a7\u5236\u8fb9\u6846\u7684\u663e\u793a\u6548\u679c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1a<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;border-box&quot;&gt;&amp;lt;\/div&gt;\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.border-box {\n  width: 100px;\n  height: 100px;\n  border: 1px solid black;\n  transform: scale(1, 0.5);\n  transform-origin: top;\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u89e3\u91ca\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>scale(1, 0.5)<\/code> \u5c06\u5143\u7d20\u5728\u5782\u76f4\u65b9\u5411\u4e0a\u7f29\u653e\u81f3\u539f\u6765\u7684\u4e00\u534a\uff0c\u8fd9\u6837\u8fb9\u6846\u5728\u89c6\u89c9\u4e0a\u663e\u5f97\u53ea\u6709 0.5px\u3002<\/li>\n\n\n\n<li><code>transform-origin: top<\/code> \u4fdd\u8bc1\u5143\u7d20\u5728\u9876\u90e8\u5bf9\u9f50\uff0c\u907f\u514d\u51fa\u73b0\u4f4d\u79fb\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 2\uff1a\u4f7f\u7528 <code>box-shadow<\/code> \u6a21\u62df\u7ec6\u8fb9\u6846<\/h2>\n\n\n\n<p>\u53e6\u4e00\u79cd\u65b9\u5f0f\u662f\u4f7f\u7528 <code>box-shadow<\/code> \u6765\u6a21\u62df\u8fb9\u6846\u6548\u679c\u3002\u901a\u8fc7\u8bbe\u7f6e <code>box-shadow<\/code> \u7684\u900f\u660e\u5ea6\u548c\u6a21\u7cca\u5ea6\uff0c\u53ef\u4ee5\u5b9e\u73b0\u975e\u5e38\u7ec6\u7684\u8fb9\u6846\u6548\u679c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1a<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;border-box&quot;&gt;&amp;lt;\/div&gt;\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.border-box {\n  width: 100px;\n  height: 100px;\n  box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.5);\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u89e3\u91ca\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>box-shadow: 0 0 0 0.5px rgba(0, 0, 0, 0.5)<\/code> \u4f7f\u7528 <strong>0.5px<\/strong> \u7684\u9634\u5f71\u6765\u6a21\u62df\u8fb9\u6846\uff0c <code>rgba(0, 0, 0, 0.5)<\/code> \u7684\u989c\u8272\u548c\u900f\u660e\u5ea6\u53ef\u4ee5\u8c03\u6574\u6765\u5f97\u5230\u671f\u671b\u7684\u6548\u679c\u3002<\/li>\n\n\n\n<li>\u8be5\u65b9\u6cd5\u4e0d\u4f1a\u88ab\u8fb9\u6846\u6e32\u67d3\u89c4\u5219\u9650\u5236\uff0c\u56e0\u6b64\u5728\u9ad8\u5206\u8fa8\u7387\u8bbe\u5907\u4e0a\u4f1a\u663e\u5f97\u66f4\u7cbe\u7ec6\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 3\uff1a\u4f7f\u7528 <code>linear-gradient<\/code> \u80cc\u666f\u6a21\u62df\u8fb9\u6846<\/h2>\n\n\n\n<p>\u901a\u8fc7 CSS \u80cc\u666f\u7684\u6e10\u53d8\uff08<code>linear-gradient<\/code>\uff09\u53ef\u4ee5\u6a21\u62df\u4e00\u4e2a\u7ec6\u8fb9\u6846\u7684\u6548\u679c\u3002\u8fd9\u79cd\u65b9\u6cd5\u53ef\u4ee5\u786e\u4fdd\u5728\u5404\u79cd\u5206\u8fa8\u7387\u4e0a\u90fd\u6709\u975e\u5e38\u4e00\u81f4\u7684\u8868\u73b0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1a<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;border-box&quot;&gt;&amp;lt;\/div&gt;\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.border-box {\n  width: 100px;\n  height: 100px;\n  background: linear-gradient(to right, transparent 0%, transparent 99.5%, black 99.5%, black 100%);\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u89e3\u91ca\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u901a\u8fc7 <code>linear-gradient<\/code> \u5728\u5143\u7d20\u7684\u8fb9\u7f18\u7ed8\u5236\u4e00\u4e2a\u63a5\u8fd1 0.5px \u5bbd\u5ea6\u7684\u7ec6\u8fb9\u6846\u3002<\/li>\n\n\n\n<li><code>99.5%<\/code> \u548c <code>100%<\/code> \u63a7\u5236\u8fb9\u6846\u7684\u5bbd\u5ea6\u548c\u4f4d\u7f6e\uff0c\u4f7f\u5f97\u5b83\u51e0\u4e4e\u770b\u8d77\u6765\u50cf\u662f\u4e00\u4e2a <strong>0.5px<\/strong> \u7684\u8fb9\u6846\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 4\uff1a\u4f7f\u7528 <code>border-image<\/code> \u5c5e\u6027<\/h2>\n\n\n\n<p><code>border-image<\/code> \u5141\u8bb8\u4f7f\u7528\u56fe\u7247\u4f5c\u4e3a\u8fb9\u6846\uff0c\u8fd9\u6837\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u56fe\u7247\u6765\u5b9e\u73b0\u7cbe\u7ec6\u7684\u8fb9\u6846\u6548\u679c\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1a<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;border-box&quot;&gt;&amp;lt;\/div&gt;\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.border-box {\n  width: 100px;\n  height: 100px;\n  border: 0.5px solid transparent;\n  border-image: linear-gradient(to right, transparent 50%, black 50%) 1 1 stretch;\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u89e3\u91ca\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>border-image<\/code> \u4f7f\u7528\u4e00\u4e2a <strong>\u7ebf\u6027\u6e10\u53d8<\/strong> \u6765\u6a21\u62df\u8fb9\u6846\u7684\u6548\u679c\uff0c\u901a\u8fc7\u8bbe\u7f6e\u6e10\u53d8\u7684\u900f\u660e\u548c\u989c\u8272\u90e8\u5206\uff0c\u521b\u5efa\u51fa 0.5px \u7684\u7cbe\u7ec6\u8fb9\u6846\u3002<\/li>\n\n\n\n<li><code>1 1 stretch<\/code> \u7528\u6765\u786e\u4fdd\u6e10\u53d8\u8fb9\u6846\u7684\u7cbe\u786e\u5ea6\uff0c\u9002\u914d\u5143\u7d20\u7684\u6bcf\u4e00\u8fb9\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u65b9\u6cd5 5\uff1a\u4f7f\u7528\u4f2a\u5143\u7d20 <code>::before<\/code> \u6216 <code>::after<\/code><\/h2>\n\n\n\n<p>\u901a\u8fc7\u5728\u5143\u7d20\u7684\u4e0a\u4e0b\u5de6\u53f3\u4f7f\u7528\u4f2a\u5143\u7d20\u6765\u6a21\u62df\u8fb9\u6846\uff0c\u53ef\u4ee5\u66f4\u52a0\u7cbe\u7ec6\u5730\u63a7\u5236\u8fb9\u6846\u7684\u539a\u5ea6\u548c\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">\u793a\u4f8b\uff1a<\/h3>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n&amp;lt;div class=&quot;border-box&quot;&gt;&amp;lt;\/div&gt;\n\n<\/pre><\/div>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: plain; title: ; notranslate\" title=\"\">\n.border-box {\n  width: 100px;\n  height: 100px;\n  position: relative;\n}\n\n.border-box::before {\n  content: &quot;&quot;;\n  position: absolute;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  border: 0.5px solid black;\n}\n\n<\/pre><\/div>\n\n\n<h3 class=\"wp-block-heading\">\u89e3\u91ca\uff1a<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u4f7f\u7528 <code>::before<\/code> \u4f2a\u5143\u7d20\uff0c\u5728\u5143\u7d20\u7684\u5916\u56f4\u521b\u5efa\u4e00\u4e2a <strong>0.5px<\/strong> \u7684\u8fb9\u6846\u3002<\/li>\n\n\n\n<li><code>position: absolute<\/code> \u4fdd\u8bc1\u4f2a\u5143\u7d20\u76f8\u5bf9\u4e8e\u7236\u5143\u7d20\u5b9a\u4f4d\uff0c\u5e76\u5b8c\u5168\u8986\u76d6\u7236\u5143\u7d20\u7684\u56db\u4e2a\u8fb9\u3002<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\u603b\u7ed3<\/h2>\n\n\n\n<p>\u8fd9\u4e9b\u65b9\u6cd5\u5404\u6709\u4f18\u7f3a\u70b9\uff0c\u9002\u7528\u4e8e\u4e0d\u540c\u7684\u573a\u666f\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"has-fixed-layout\"><thead><tr><th>\u65b9\u6cd5<\/th><th>\u9002\u7528\u573a\u666f<\/th><th>\u4f18\u70b9<\/th><th>\u7f3a\u70b9<\/th><\/tr><\/thead><tbody><tr><td><strong>\u65b9\u6cd5 1\uff1atransform<\/strong><\/td><td>\u52a8\u753b\u3001\u9700\u8981\u7f29\u653e\u7684\u8fb9\u6846<\/td><td>\u53ef\u4ee5\u7cbe\u7ec6\u63a7\u5236<\/td><td>\u5bf9\u4f4d\u7f6e\u6709\u5f71\u54cd\uff0c\u53ef\u80fd\u5bfc\u81f4\u9519\u4f4d<\/td><\/tr><tr><td><strong>\u65b9\u6cd5 2\uff1abox-shadow<\/strong><\/td><td>\u80cc\u666f\u8272\u4e0e\u8fb9\u6846\u6548\u679c\u76f8\u7ed3\u5408\u7684\u9700\u6c42<\/td><td>\u4e0d\u5f71\u54cd\u5143\u7d20\u4f4d\u7f6e\uff0c\u517c\u5bb9\u6027\u597d<\/td><td>\u9700\u8981\u8c03\u8282\u9634\u5f71\u900f\u660e\u5ea6<\/td><\/tr><tr><td><strong>\u65b9\u6cd5 3\uff1alinear-gradient<\/strong><\/td><td>\u80cc\u666f\u56fe\u6848\u4e0e\u8fb9\u6846\u6548\u679c\u7684\u9700\u6c42<\/td><td>\u4e0d\u53d7\u8fb9\u6846\u5bbd\u5ea6\u9650\u5236\uff0c\u8868\u73b0\u7a33\u5b9a<\/td><td>\u9700\u8981\u624b\u52a8\u8c03\u6574\u6e10\u53d8\u7684\u4f4d\u7f6e\u548c\u989c\u8272<\/td><\/tr><tr><td><strong>\u65b9\u6cd5 4\uff1aborder-image<\/strong><\/td><td>\u8fb9\u6846\u9700\u8981\u6e10\u53d8\u6216\u56fe\u6848\u7684\u9700\u6c42<\/td><td>\u63a7\u5236\u7cbe\u786e\u4e14\u6548\u679c\u4e30\u5bcc<\/td><td>\u590d\u6742\u7684\u914d\u7f6e\uff0c\u4e0d\u9002\u7528\u4e8e\u5355\u7eaf\u7684\u8fb9\u6846<\/td><\/tr><tr><td><strong>\u65b9\u6cd5 5\uff1a\u4f2a\u5143\u7d20<\/strong><\/td><td>\u7b80\u5355\u7684\u8fb9\u6846\u6548\u679c<\/td><td>\u4e0d\u5e72\u6270\u5176\u4ed6\u5143\u7d20\u7684\u5e03\u5c40<\/td><td>\u9700\u8981\u989d\u5916\u7684 HTML \u7ed3\u6784\u652f\u6301<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>\u5982\u679c\u4f60\u5e0c\u671b\u521b\u5efa\u8d85\u7ec6\u7684\u8fb9\u6846\u4e14\u4fdd\u6301\u8de8\u8bbe\u5907\u7684\u517c\u5bb9\u6027\uff0c<strong>\u4f7f\u7528 <code>box-shadow<\/code> \u6216 <code>linear-gradient<\/code> \u6a21\u62df\u8fb9\u6846<\/strong>\u53ef\u80fd\u662f\u6700\u7b80\u4fbf\u4e14\u7a33\u5b9a\u7684\u89e3\u51b3\u65b9\u6848\u3002\u4f60\u53ef\u4ee5\u6839\u636e\u5177\u4f53\u9700\u6c42\u9009\u62e9\u5408\u9002\u7684\u5b9e\u73b0\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>\u5982\u679c\u6709\u5176\u4ed6\u95ee\u9898\u6216\u9700\u8981\u8fdb\u4e00\u6b65\u7684\u5e2e\u52a9\uff0c\u8bf7\u968f\u65f6\u544a\u77e5\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728\u7f51\u9875\u8bbe\u8ba1\u4e2d\uff0c\u5f88\u591a\u65f6\u5019\u9700\u8981\u5b9e\u73b0\u975e\u5e38\u7ec6\u7684\u8fb9\u6846\uff0c\u6bd4\u5982 0.5px \u7684\u7ec6\u8fb9\u6846\u3002\u7136\u800c\uff0cC&#8230; <a class=\"more-link\" href=\"https:\/\/www.52runoob.com\/index.php\/2025\/12\/20\/css%e5%ae%9e%e7%8e%b00-5px%ef%bc%88%e7%89%a9%e7%90%86%e5%83%8f%e7%b4%a0%ef%bc%89%e7%9a%84%e7%bb%86%e8%be%b9%e6%a1%86%e7%9a%845%e7%a7%8d%e6%96%b9%e6%b3%95\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-832","post","type-post","status-publish","format-standard","hentry","category-css"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/832","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/comments?post=832"}],"version-history":[{"count":1,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/832\/revisions"}],"predecessor-version":[{"id":833,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/posts\/832\/revisions\/833"}],"wp:attachment":[{"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/media?parent=832"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/categories?post=832"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.52runoob.com\/index.php\/wp-json\/wp\/v2\/tags?post=832"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}