{"id":9962,"date":"2021-05-30T00:47:39","date_gmt":"2021-05-29T16:47:39","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=9962"},"modified":"2021-05-30T00:51:56","modified_gmt":"2021-05-29T16:51:56","slug":"css-html-hr","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2021\/05\/css-html-hr\/","title":{"rendered":"666\uff0c\u770bhr\u6807\u7b7e\u5b9e\u73b0\u5206\u9694\u7ebf\u5982\u4f55\u73a9\u51fa\u82b1"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=9962\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=9962<\/a><br \/>\n\u672c\u6587\u6b22\u8fce\u5206\u4eab\u4e0e\u805a\u5408\uff0c\u5168\u6587\u8f6c\u8f7d\u5c31\u4e0d\u5fc5\u4e86\uff0c\u5c0a\u91cd\u7248\u6743\uff0c\u5708\u5b50\u5c31\u8fd9\u4e48\u5927\uff0c\u82e5\u6025\u7528\u53ef\u4ee5\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<p><script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/202105-css-hr.png';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202105\/css-hr-cover.png\" width=\"480\" height=\"307\" alt=\"\u8349\u6ce5\u9a6c \u7b80\u7b14\u753b html hr\" class=\"alignright thumb clip size-medium\" \/><\/p>\n<p>\u65e5\u5e38\u5f00\u53d1\u7ecf\u5e38\u4f1a\u7528\u5230\u7f51\u9875\u5206\u9694\u7ebf\uff0c\u4f8b\u5982\u5217\u8868\u4e0b\u62c9\u5230\u6700\u540e\uff0c\u7c7b\u4f3c\u4e8e\u201c\u6211\u662f\u6709\u5e95\u7ebf\u7684\u201d\u8fd9\u6837\u7684\u63d0\u793a\uff0c\u5c31\u4f1a\u4f34\u968f\u5206\u9694\u7ebf\u3002<\/p>\n<p>\u901a\u5e38\uff0c\u8fd9\u6837\u7684\u5206\u9694\u7ebf\u662f\u4f7f\u7528<code>&lt;div&gt;<\/code>\u6807\u7b7e\u6a21\u62df\u7684\uff0c\u5176\u5b9e\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528\u8bed\u4e49\u66f4\u597d\u7684<code>&lt;hr&gt;<\/code>\u6807\u7b7e\u6a21\u62df\u3002<\/p>\n<p>HTML <code>&lt;hr&gt;<\/code>\u5143\u7d20\u867d\u7136\u662f\u4e00\u4e2a\u975e\u95ed\u5408\u6807\u7b7e\uff0c\u4f46\u662f\u4e5f\u662f\u652f\u6301<code>::before<\/code>\u548c<code>::after<\/code>\u4f2a\u5143\u7d20\u7684\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>&lt;hr&gt;<\/code>\u6807\u7b7e\u5b9e\u73b0\u5404\u79cd\u6837\u5f0f\u7684\u5206\u9694\u7ebf\u6548\u679c\u3002<\/p>\n<link rel=\"stylesheet\" href=\"\/study\/202105\/hr.css\">\n<h3>\u4e00\u3001\u57fa\u7840\u5206\u9694\u7ebf\u6548\u679c<\/h3>\n<h5>\u5b9e\u7ebf<\/h5>\n<p>\u76f8\u5173HTML\u548cCSS\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>&lt;hr class=\"hr-solid\"&gt;<\/pre>\n<pre>.hr-solid {\r\n    border: 0;\r\n    border-top: 1px solid #d0d0d5;\r\n}<\/pre>\n<p>\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-solid\">\n<h5>\u70b9\u7ebf\uff081px\u548c2px\uff09<\/h5>\n<p>\u76f8\u5173HTML\u548cCSS\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff0c\u4f7f\u7528\u7684\u662f\u6d4f\u89c8\u5668\u9ed8\u8ba4\u6548\u679c\uff0c\u56e0\u6b64\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u4e0b\u770b\u5230\u7684\u865a\u70b9\u7684\u7ec6\u8282\u53ef\u80fd\u4f1a\u6709\u6240\u5dee\u5f02\uff1a<\/p>\n<pre>&lt;hr class=\"hr-dotted\"&gt;\r\n&lt;hr class=\"hr-dotted2\"&gt;<\/pre>\n<pre>.hr-dotted {\r\n    border: 0;\r\n    border-top: 1px dotted #a2a9b6;\r\n}\r\n.hr-dotted2 {\r\n    border: 0;\r\n    border-top: 2px dotted #a2a9b6;\r\n}<\/pre>\n<p>\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-dotted\">\n<hr class=\"hr-dotted2\">\n<h5>\u865a\u7ebf\uff081px\u548c2px\uff09<\/h5>\n<p>\u76f8\u5173HTML\u548cCSS\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff0c\u540c\u6837\u7684\uff0c\u6d4f\u89c8\u5668\u9ed8\u8ba4\u865a\u7ebf\u6837\u5f0f\uff0c\u4e0d\u540c\u6d4f\u89c8\u5668\u8868\u73b0\u7ec6\u8282\u6709\u5dee\u5f02\uff1a<\/p>\n<pre>&lt;hr class=\"hr-dashed\"&gt;\r\n&lt;hr class=\"hr-dashed2\"&gt;<\/pre>\n<pre>.hr-dashed {\r\n    border: 0;\r\n    border-top: 1px dashed #a2a9b6;\r\n}\r\n.hr-dashed2 {\r\n    border: 0;\r\n    border-top: 2px dashed #a2a9b6;\r\n}<\/pre>\n<p>\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-dashed\">\n<hr class=\"hr-dashed2\">\n<h5>\u53cc\u5b9e\u7ebf<\/h5>\n<p>\u76f8\u5173HTML\u548cCSS\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>&lt;hr class=\"hr-double\"&gt;<\/pre>\n<pre>.hr-double {\r\n    border: 0;\r\n    border-top: 3px double #d0d0d5;\r\n}<\/pre>\n<p>\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-double\">\n<h5>\u758f\u5bc6\u53ef\u63a7\u7684\u865a\u7ebf<\/h5>\n<p>\u8fd9\u91cc\u4f7f\u7528\u7ebf\u6027\u6e10\u53d8\u6a21\u62df\u865a\u7ebf\u6548\u679c\uff0c\u4f18\u70b9\u662f\u865a\u7ebf\u7684\u865a\u5b9e\u6bd4\u4f8b\u662f\u53ef\u4ee5\u7cbe\u786e\u63a7\u5236\u7684\uff0c\u5b9e\u73b0\u539f\u7406\u548c\u7ec6\u8282\u4ee5\u524d\u4ecb\u7ecd\u8fc7\uff0c\u53ef\u53c2\u89c1\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=6494\">CSS3 linear-gradient\u7ebf\u6027\u6e10\u53d8\u5b9e\u73b0\u865a\u7ebf<\/a>\u201d\u4e00\u6587\u3002<\/p>\n<p>\u73b0\u5728\u6709\u5982\u4e0b\u6240\u793a\u7684HTML\u548cCSS\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;hr class=\"hr-dashed-fixed\"&gt;<\/pre>\n<pre>.hr-dashed-fixed {\r\n    border: 0;\r\n    padding-top: 1px;\r\n    background: repeating-linear-gradient(to right, #a2a9b6 0px, #a2a9b6 4px, transparent 0px, transparent 10px);\r\n<\/pre>\n<p>\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-dashed-fixed\">\n<p>\u8fd9\u91cc\uff0c\u4e3a\u4e86\u65b9\u4fbf\u5927\u5bb6\u4f7f\u7528\uff0c\u6211\u53c8\u4f7f\u7528CSS\u53d8\u91cf\uff0c\u628a\u865a\u7ebf\u5b9e\u7ebf\u6bd4\u4f8b\u505a\u6210\u53ef\u914d\u7f6e\u7684\u4e86\u3002<\/p>\n<p>\u5176\u4e2d<code>--dashed-filled<\/code>\u662f\u5b9e\u7ebf\u5c3a\u5bf8\uff0c\u53d8\u91cf<code>--dashed-filled<\/code>\u662f\u865a\u7ebf\u7684\u5c3a\u5bf8\uff0c\u4ee3\u7801\u793a\u610f\uff1a<\/p>\n<pre>&lt;hr class=\"hr-dashed-fixed\" style=\"--dashed-filled: 6px; --dashed-open: 5px;\"&gt;<\/pre>\n<pre>.hr-dashed-fixed {\r\n    border: 0;\r\n    padding-top: 1px;\r\n    <span style=\"color:green;\">\/* for \u73b0\u4ee3\u6d4f\u89c8\u5668 *\/<\/span>\r\n    background: repeating-linear-gradient(to right, #a2a9b6 0 var(--dashed-filled, 4px), transparent 0 calc(var(--dashed-filled, 4px) + var(--dashed-open, 6px)));\r\n}<\/pre>\n<p>\u5b9e\u65f6\u6e32\u67d3\u7ed3\u679c\u5982\u4e0b\uff0c\u53ea\u6709\u5728\u73b0\u4ee3\u6d4f\u89c8\u5668\u4e2d\u624d\u6709\u6548\u679c\uff0c\u56e0\u4e3aIE\u4e0d\u652f\u6301CSS\u53d8\u91cf\uff0c\u56e0\u6b64\uff0cIE\u6d4f\u89c8\u5668\u65e0\u6548\u3002<\/p>\n<hr class=\"hr-dashed-fixed\" style=\"--dashed-filled: 6px; --dashed-open: 5px;\">\n<p>\u4e3a\u4e86\u5168\u517c\u5bb9\uff0c\u5927\u5bb6\u53ef\u4ee5\u628a\u4e0a\u9762\u4e24\u6bb5CSS\u5408\u4e8c\u4e3a\u4e00\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre>.hr-dashed-fixed {\r\n    border: 0;\r\n    padding-top: 1px;\r\n    <span style=\"color:green;\">\/* for IE\u6d4f\u89c8\u5668 *\/<\/span>\r\n    background: repeating-linear-gradient(to right, #a2a9b6 0px, #a2a9b6 4px, transparent 0px, transparent 10px);\r\n    <span style=\"color:green;\">\/* for \u73b0\u4ee3\u6d4f\u89c8\u5668 *\/<\/span>\r\n    background: repeating-linear-gradient(to right, #a2a9b6 0 var(--dashed-filled, 4px), transparent 0 calc(var(--dashed-filled, 4px) + var(--dashed-open, 6px)));\r\n}<\/pre>\n<h5>\u4e24\u5934\u865a\u7684\u5206\u9694\u7ebf<\/h5>\n<p>\u8fd9\u662f\u4e2a\u6bd4\u8f83\u5e38\u89c1\u7684\u5206\u9694\u7ebf\u6548\u679c\uff0c\u7ebf\u7684\u4e24\u7aef\u6de1\u51fa\uff0c\u4e2d\u95f4\u662f\u5b8c\u6574\u7684\u989c\u8272\u3002<\/p>\n<p>\u6b64\u6548\u679c\u5b9e\u73b0\u65b9\u6cd5\u5f88\u591a\uff0c\u6211\u8fd9\u91cc\u4f7f\u7528\u7684\u662fCSS\u6e10\u53d8\u6a21\u62df\u7684\uff0c\u76f8\u5173HTML\u548cCSS\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>&lt;hr class=\"hr-edge-weak\"&gt;<\/pre>\n<pre>.hr-edge-weak {\r\n    border: 0;\r\n    padding-top: 1px;\r\n    background: linear-gradient(to right, transparent, #d0d0d5, transparent);\r\n}<\/pre>\n<p>\u5b9e\u65f6\u6e32\u67d3\u6548\u679c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<hr class=\"hr-edge-weak\">\n<h5>\u659c\u7eb9\u5206\u9694\u7ebf<\/h5>\n<p>\u6709\u65f6\u5019\u9700\u8981\u5206\u754c\u7ebf\u66f4\u52a0\u660e\u663e\u7684\u5206\u9694\u7ebf\uff0c\u5219\u53ef\u4ee5\u8bd5\u8bd5\u4e0b\u9762\u7684\u4ee3\u7801\uff0c\u5bf9\u5e94\u7684\u6548\u679c\u662f\u659c\u7eb9\u5206\u9694\u7ebf\u3002<\/p>\n<pre>&lt;hr class=\"hr-twill\"&gt;<\/pre>\n<pre>.hr-twill {\r\n    border: 0;\r\n    padding: 3px;\r\n    background: repeating-linear-gradient(135deg, #a2a9b6 0px, #a2a9b6 1px, transparent 1px, transparent 6px);\r\n}<\/pre>\n<p>\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-twill\">\n<p>\u6211\u4eec\u4e5f\u53ef\u4ee5\u8ba9\u659c\u7eb9\u8868\u73b0\u4e3a\u591a\u5f69\u7684\u989c\u8272\uff0c\u8fd9\u91cc\u4f7f\u7528\u4e86\u906e\u7f69\u5b9e\u73b0\uff0cHTML\u548cCSS\u4ee3\u7801\u4e3a\uff1a<\/p>\n<pre>&lt;hr class=\"hr-twill-colorful\"&gt;<\/pre>\n<pre><span style=\"color:green;\">\/* \u73b0\u4ee3\u6d4f\u89c8\u5668only *\/<\/span>\r\n.hr-twill-colorful {\r\n    border: 0;\r\n    padding: 3px;\r\n    background: linear-gradient(135deg, red, orange,green, blue, purple);\r\n    --mask-image: repeating-linear-gradient(135deg, #000 0px, #000 1px, transparent 1px, transparent 6px);\r\n    -webkit-mask-image: var(--mask-image);\r\n    mask-image: var(--mask-image);\r\n}<\/pre>\n<p>\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-twill-colorful\">\n<h5>\u6ce2\u6d6a\u7ebf<\/h5>\n<p>\u8fd9\u91cc\u7684\u6ce2\u6d6a\u7ebf\u5b9e\u73b0\u4f7f\u7528\u4e86\u7279\u522b\u7684\u6280\u5de7\uff0c\u76f8\u5173\u539f\u7406\u548c\u7ec6\u8282\u4e4b\u524d\u4e13\u95e8\u64b0\u6587\u4ecb\u7ecd\u8fc7\uff0c\u8be6\u89c1\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=9333\">CSS text-decoration\u5b9e\u73b0\u5bbd\u5ea6100%\u6ce2\u6d6a\u7ebf\u6548\u679c<\/a>\u201d\u3002<\/p>\n<p>\u8fd9\u91cc\u6f14\u793a\u4f7f\u7528\u7684\u524d\u7aef\u4ee3\u7801\u5219\u662f\uff1a<\/p>\n<pre>&lt;hr class=\"hr-wavy\"&gt;<\/pre>\n<pre>.hr-wavy {\r\n    border: 0;\r\n    color: #d0d0d5;\r\n    height: .5em;\r\n    white-space: nowrap;\r\n    letter-spacing: 100vw;\r\n    padding-top: .5em;\r\n}\r\n.hr-wavy::before {\r\n    content: \"\\2000\\2000\";\r\n    <span style=\"color:green;\">\/* IE\u6d4f\u89c8\u5668\u5b9e\u7ebf\u4ee3\u66ff *\/<\/span>\r\n    text-decoration: overline;\r\n    <span style=\"color:green;\">\/* \u73b0\u4ee3\u6d4f\u89c8\u5668 *\/<\/span>\r\n    text-decoration: overline wavy;\r\n}<\/pre>\n<p>\u6548\u679c\u4f53\u9a8c\uff1a<\/p>\n<hr class=\"hr-wavy\">\n<h5>\u9634\u5f71\u7ebf<\/h5>\n<p>\u8fd9\u4e2a\u5b9e\u73b0\u6bd4\u8f83\u7b80\u5355\uff0c\u5c31\u662f\u4f7f\u7528CSS <code>box-shadow<\/code>\u76d2\u9634\u5f71\u5c5e\u6027\uff0c\u591a\u7528\u5728\u8868\u793a\u5c42\u6b21\u7684\u5206\u9694\u573a\u666f\u4e2d\u3002<\/p>\n<p>\u76f8\u5173HTML\u548cCSS\u4ee3\u7801\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>&lt;hr class=\"hr-shadow\"&gt;<\/pre>\n<pre>.hr-shadow {\r\n    border: 0;\r\n    padding-top: 10px;\r\n    color: #d0d0d5;\r\n    border-top: 1px solid rgba(0,0,0,.1);\r\n    box-shadow: inset 0 10px 10px -10px;\r\n}\r\n<\/pre>\n<p>\u5e26\u9634\u5f71\u7684\u5206\u9694\u7ebf\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-shadow\">\n<h3>\u4e8c\u3001\u5e26\u70b9\u56fe\u5f62\u88c5\u9970\u7684\u5206\u9694\u7ebf<\/h3>\n<p>\u8fd9\u91cc\u4e3b\u8981\u6f14\u793a\u51e0\u4e2a\u751f\u4ea7\u73af\u5883\u53ef\u4ee5\u4f7f\u7528\u7684\u51e0\u4e2a\u6837\u5f0f\uff0c\u90a3\u4e9b\u82b1\u91cc\u80e1\u54e8\u7684\u5206\u9694\u7ebf\u8fd9\u91cc\u5c31\u4e0d\u5c55\u793a\u4e86\u3002<\/p>\n<h5>\u4e2d\u95f4\u6709\u88c5\u9970<\/h5>\n<p>\u4e2d\u95f4\u6709\u4e00\u4e9b\u56fe\u5f62\u6216\u56fe\u50cf\uff0c\u5b9e\u73b0\u539f\u7406\u5927\u540c\u5c0f\u5f02\uff0c\u8fd9\u91cc\u4f7f\u7528\u5706\u548c\u65b9\u5757\u629b\u7816\u5f15\u7389\u793a\u610f\u4e0b\u3002<\/p>\n<pre>&lt;hr class=\"hr-mid-circle\"&gt;\r\n&lt;hr class=\"hr-mid-square\"&gt;<\/pre>\n<p>\u8fd9\u91cc\u7684\u7ebf\u6761\u4f7f\u7528CSS\u6e10\u53d8\u7ed8\u5236\uff0c\u800c\u4e2d\u95f4\u7684\u56fe\u5f62\u5c31\u9700\u8981\u501f\u52a9\u4f2a\u5143\u7d20\u5b9e\u73b0\u4e86\u3002<\/p>\n<pre>.hr-mid-circle,\r\n.hr-mid-square {\r\n    border: 0;\r\n    color: #d0d0d5;\r\n    background: linear-gradient(currentColor, currentColor) no-repeat center;\r\n    background-size: 100% 1px;\r\n}\r\n.hr-mid-circle::before {\r\n    content: '';\r\n    display: block;\r\n    width: .75em; height: .75em;\r\n    border-radius: 50%;\r\n    background-color: currentColor;\r\n    margin: auto;\r\n}\r\n.hr-mid-square::before {\r\n    content: '';\r\n    display: block;\r\n    width: .75em; height: .75em;\r\n    transform: rotate(45deg);\r\n    background-color: currentColor;\r\n    margin: 3px auto;\r\n}<\/pre>\n<p>\u5927\u5bb6\u5e94\u8be5\u53ef\u4ee5\u770b\u5230\u5982\u4e0b\u6240\u793a\u7684\u6548\u679c\uff0c\u5982\u679c\u6ca1\u6709\u6548\u679c\uff0c\u770b\u770b\u57df\u540d\u662f\u4e0d\u662fzhangxinxu.com\uff0c\u8c28\u9632\u5047\u5192\u3002<\/p>\n<hr class=\"hr-mid-circle\">\n<hr class=\"hr-mid-square\">\n<h5>\u4e2d\u95f4\u6709\u591a\u4e2a\u88c5\u9970<\/h5>\n<p>\u5982\u679c\u4e2d\u95f4\u662f\u591a\u4e2a\u5706\uff0c\u591a\u4e2a\u65b9\u5757\uff0c\u90a3\u8be5\u600e\u4e48\u529e\u5462\uff1f<\/p>\n<p>\u4e00\u79cd\u65b9\u6cd5\u662f\u53d8\u6210\u80cc\u666f\u56fe\uff0c\u5e73\u94fa\uff0c\u5728\u672c\u4f8b\u4e2d\uff0c\u56e0\u4e3a\u662f\u5b9e\u8272\u56fe\u5f62\uff0c\u5219\u53ef\u4ee5\u4f7f\u7528 <code>box-shadow<\/code> \u8fdb\u884c\u56fe\u5f62\u590d\u5236\u3002<\/p>\n<pre>&lt;hr class=\"hr-mid-circle\" multiple&gt;\r\n&lt;hr class=\"hr-mid-square\" multiple&gt;<\/pre>\n<p>\u53ea\u9700\u8981\u5728\u4e0a\u9762CSS\u4ee3\u7801\u57fa\u7840\u4e0a\u52a0\u4e0a\u4e0b\u9762\u8fd9\u51e0\u884cCSS\u5c31\u53ef\u4ee5\u4e86\uff1a<\/p>\n<pre>.hr-mid-circle[multiple]::before {\r\n    box-shadow: 1.5em 0, -1.5em 0;\r\n}\r\n.hr-mid-square[multiple]::before {\r\n    box-shadow: 1.25em -1.25em, -1.25em 1.25em;;\r\n}<\/pre>\n<p>\u6b64\u65f6\u7684\u6d4f\u89c8\u5668\u6e32\u67d3\u6548\u679c\u5219\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<hr class=\"hr-mid-circle\" multiline>\n<hr class=\"hr-mid-square\" multiline>\n<h5>\u88c5\u9970\u5728\u4e24\u7aef<\/h5>\n<p>\u88c5\u9970\u6709\u53ef\u80fd\u5728\u4e24\u7aef\uff0c\u800c\u4e0d\u662f\u4e2d\u95f4\uff0c\u8fd9\u91cc\u6f14\u793a\u4e00\u4e2a\u94bb\u77f3\u56fe\u5f62\u5728\u4e24\u4fa7\u5bf9\u9f50\u7684\u4f8b\u5b50\uff0cHTML\u548cCSS\u4f7f\u7528\u7684\u662f\uff1a<\/p>\n<pre>&lt;hr class=\"hr-space-square\"&gt;<\/pre>\n<pre>.hr-space-square {\r\n    border: 0;\r\n    color: #d0d0d5;\r\n    background: linear-gradient(currentColor, currentColor) no-repeat center;\r\n    background-size: calc(100% - 1.5em - 6px) 1px;\r\n    display: flex;\r\n    justify-content: space-between;\r\n}\r\n.hr-space-square::before,\r\n.hr-space-square::after {\r\n    content: '';\r\n    display: block;\r\n    width: .75em; height: .75em;\r\n    transform: rotate(45deg);\r\n    box-sizing: border-box;\r\n    border: 1px solid;\r\n    margin: 3px;\r\n}<\/pre>\n<p>\u53ef\u4ee5\u770b\u5230\u4e0b\u9762\u8fd9\u6837\u7684\u6548\u679c\u3002<\/p>\n<hr class=\"hr-space-square\">\n<h5>\u88c5\u9970\u590d\u6742\u4e00\u70b9\u70b9<\/h5>\n<p>\u5c31\u662f\u7ebf\u6761\u591a\u4e00\u70b9\uff0c\u56fe\u5f62\u7684\u9020\u578b\u4e5f\u7a0d\u5fae\u590d\u6742\u4e00\u70b9\u7684\u88c5\u9970\u6548\u679c\uff0cHTML\u6bd4\u8f83\u7b80\u5355\uff1a<\/p>\n<pre>&lt;hr class=\"hr-double-arrow\"&gt;<\/pre>\n<p>CSS\u8fd9\u91cc\u7528\u5230\u4e86\u5b9a\u4f4d\u8fd8\u6709\u4e00\u4e9b\u5e38\u89c1\u7684CSS\u56fe\u5f62\u751f\u6210\u6280\u5de7\uff1a<\/p>\n<pre>.hr-double-arrow {\r\n    color: #d0d0d5;\r\n    border: double;\r\n    border-width: 3px 5px;\r\n    border-color: #d0d0d5 transparent;\r\n    height: 1px;\r\n    overflow: visible;\r\n    margin-left: 20px;\r\n    margin-right: 20px;\r\n    position: relative;\r\n}\r\n.hr-double-arrow:before, \r\n.hr-double-arrow:after {\r\n    content: '';\r\n    position: absolute;\r\n    width: 5px; height: 5px;\r\n    border-width: 0 3px 3px 0;\r\n    border-style: double;\r\n    top: -3px;\r\n    background: radial-gradient(2px at 1px 1px, currentColor 2px, transparent 0) no-repeat;\r\n}\r\n.hr-double-arrow:before {\r\n    transform: rotate(-45deg);\r\n    left: -20px;\r\n}\r\n.hr-double-arrow:after {\r\n    transform: rotate(135deg);\r\n    right: -20px;\r\n}<\/pre>\n<p>\u6548\u679c\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<hr class=\"hr-double-arrow\">\n<p><span class=\"hidden\">\/\/zxx: \u5982\u679c\u4f60\u770b\u5230\u8fd9\u6bb5\u6587\u5b57\uff0c\u8bf4\u660e\u4f60\u73b0\u5728\u8bbf\u95ee\u662f\u4f53\u9a8c\u7cdf\u7cd5\u7684\u5783\u573e\u76d7\u7248\u7f51\u7ad9\uff0c\u4f60\u53ef\u4ee5\u8bbf\u95ee\u539f\u6587\u83b7\u5f97\u5f88\u597d\u7684\u4f53\u9a8c\uff1ahttps:\/\/www.zhangxinxu.com\/wordpress\/?p=9962\uff08\u4f5c\u8005\u5f20\u946b\u65ed\uff09<\/span><\/p>\n<p>\u8fd8\u6709\u5176\u4ed6\u4e00\u4e9b\u88c5\u9970\u6548\u679c\uff0c\u4f8b\u5982\u4e00\u4e9b\u661f\u661f\u554a\uff0c\u52a0\u4e00\u4e9b\u82b1\u6735\u4e4b\u7c7b\u7684\uff0c\u7bc7\u5e45\u539f\u56e0\uff08\u5b9e\u9645\u4e0a\u61d2\u5f97\u6298\u817e\uff0c\u9700\u8981\u4f7f\u7528SVG\u56fe\u5f62\uff09\uff0c\u5c31\u4e0d\u5c55\u793a\u4e86\u3002<\/p>\n<h3>\u4e09\u3001\u5e26\u6587\u5b57\u5185\u5bb9\u7684\u5206\u9694\u7ebf<\/h3>\n<p>\u8fd9\u4e2a\u53ef\u80fd\u7528\u5f97\u66f4\u591a\u4e00\u70b9\uff0c\u7136\u540e\u8fd9\u91cc\u6f14\u793a\u7684\u6548\u679cCSS\u4ee3\u7801\u90fd\u5927\u540c\u5c0f\u5f02\uff0c\u56e0\u6b64\u6709\u4e9b\u91cd\u590d\u7684CSS\u5c31\u4e0d\u518d\u5c55\u793a\u4e86\u3002<\/p>\n<h5>\u4e24\u7aef\u5b9e\u7ebf<\/h5>\n<p>HTML\u4ee3\u7801\u8fd9\u6837\u7684\uff1a<\/p>\n<pre>&lt;hr class=\"hr-solid-content\" data-content=\"\u5206\u9694\u7ebf\"&gt;\r\n&lt;hr class=\"hr-solid-content\" data-content=\"\u6587\u5b57\u81ea\u9002\u5e94\uff0c\u80cc\u666f\u900f\u660e\"&gt;<\/pre>\n<p>CSS\u4ee3\u7801\u5982\u4e0b\uff0c\u8fd9\u91cc\u7684\u5b9e\u73b0\u8fd8\u662f\u9700\u8981\u70b9\u57fa\u672c\u529f\u7684\uff0c\u56e0\u4e3a\u8981\u8ba9\u5de6\u53f3\u56fe\u5f62\u81ea\u9002\u5e94\u4e8e\u6587\u5b57\u5185\u5bb9\uff0c\u540c\u65f6\u6587\u5b57\u540e\u9762\u4e0d\u80fd\u6709\u80cc\u666f\u8272\u3002<\/p>\n<pre>.hr-solid-content {\r\n    color: #a2a9b6;\r\n    border: 0;\r\n    font-size: 12px;\r\n    padding: 1em 0;\r\n    position: relative;\r\n}\r\n.hr-solid-content::before {\r\n    content: attr(data-content);\r\n    position: absolute;\r\n    padding: 0 1ch;\r\n    line-height: 1px;\r\n    border: solid #d0d0d5;\r\n    border-width: 0 99vw;\r\n    width: fit-content;\r\n    <span style=\"color:green;\">\/* for \u4e0d\u652f\u6301fit-content\u6d4f\u89c8\u5668 *\/<\/span>\r\n    white-space: nowrap;\r\n    left: 50%;\r\n    transform: translateX(-50%);\r\n}<\/pre>\n<p>\u6700\u7ec8\u5b9e\u73b0\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-solid-content\" data-content=\"\u5206\u9694\u7ebf\">\n<hr class=\"hr-solid-content\" data-content=\"\u6587\u5b57\u81ea\u9002\u5e94\uff0c\u80cc\u666f\u900f\u660e\">\n<h5>\u4e24\u7aef\u865a\u7ebf<\/h5>\n<p>\u5b9e\u73b0\u539f\u7406\u548c\u4e0a\u9762\u5b9e\u7ebf\u6709\u4e9b\u7c7b\u4f3c\uff0c\u4e5f\u662f\u4f7f\u7528\u4e00\u4e2a\u5de8\u5927\u7684\u8fb9\u6846\uff0c\u4f46\u662f\uff0c\u6b64\u65f6\u4f7f\u7528dashed\u865a\u7ebf\u8fb9\u6846\u662f\u6ca1\u6709\u6548\u679c\u7684\uff0c\u56e0\u4e3a\u8fb9\u6846\u5bbd\u5ea6\u592a\u5bbd\uff0c\u9ad8\u5ea6\u4e3a0\uff0c\u865a\u7ebf\u7684\u6e32\u67d3\u662f\u6309\u7167\u6bd4\u4f8b\u6765\u7684\u3002<\/p>\n<p>\u8fd9\u91cc\u6211\u662f\u4f7f\u7528\u7684<code>border-image<\/code>\u914d\u5408\u91cd\u590d\u7ebf\u6027\u6e10\u53d8\u6a21\u62df\u7684\u865a\u7ebf\u8fb9\u6846\u6548\u679c\uff0cHTML\u4ee3\u7801\u4e3a\uff1a<\/p>\n<pre>&lt;hr class=\"hr-dashed-content\" data-content=\"\u5206\u9694\u7ebf\"&gt;<\/pre>\n<p>CSS\u4ee3\u7801\uff0c<code>.hr-dashed-content<\/code>\u9700\u8981\u7684CSS\u4ee3\u7801\u548c\u4e0a\u9762<code>.hr-solid-content<\/code>\u4e00\u6a21\u4e00\u6837\uff0c\u7136\u540e\uff0c\u989d\u5916\u589e\u52a0\u4e0b\u9762\u8fd9\u884cCSS\uff1a<\/p>\n<pre>.hr-dashed-content::before {\r\n    border-image: repeating-linear-gradient(90deg, #d0d0d5, #d0d0d5 1px, transparent 1px, transparent 2px) 0 85% \/ \/ 0 repeat;\r\n}<\/pre>\n<p>\u4e0a\u9762\u7684\u8bed\u6cd5\u770b\u4e0d\u61c2\u6ca1\u5173\u7cfb\uff0c\u77e5\u9053\u4e0a\u9762\u4ee3\u7801\u6709\u6548\u679c\u5c31\u53ef\u4ee5\u4e86\uff0c\u7136\u540e85%\u4fee\u6539\u53ef\u4ee5\u63a7\u5236\u865a\u7ebf\u7684\u5c3a\u5bf8\u5927\u5c0f\u3002<\/p>\n<p>\u5b9e\u73b0\u7684\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<hr class=\"hr-dashed-content\" data-content=\"\u5206\u9694\u7ebf\">\n<h5>\u4e24\u7aef\u6de1\u51fa<\/h5>\n<p>\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;hr class=\"hr-fade-content\" data-content=\"\u5206\u9694\u7ebf\"&gt;<\/pre>\n<p>\u5728\u539f\u6765\u5b9e\u7ebf\u6548\u679c\u57fa\u7840\u4e0a\u4f7f\u7528\u6e10\u53d8\u4f5c\u4e3a\u906e\u7f69\u5c31\u53ef\u4ee5\u5b9e\u73b0\u8fd9\u6837\u7684\u6548\u679c\u4e86\uff1a<\/p>\n<pre><span style=\"color:green;\">\/\/ ... \u4e00\u81f4\u4ee3\u7801\u7565<\/span>\r\n.hr-fade-content {\r\n    -webkit-mask-image: linear-gradient(to right, transparent, black, transparent);\r\n    mask-image: linear-gradient(to right, transparent, black, transparent);\r\n}<\/pre>\n<p>\u6548\u679c\u5c31\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<hr class=\"hr-fade-content\" data-content=\"\u5206\u9694\u7ebf\">\n<h5>\u5185\u5bb9\u88c5\u9970<\/h5>\n<p>\u5982\u679c\u5e0c\u671b\u5185\u5bb9\u7528\u6846\u6846\u8d77\u6765\uff0c\u52a0\u4e2a\u80cc\u666f\u4ec0\u4e48\u7684\uff0c\u5219\u9700\u8981\u501f\u52a9\u53e6\u5916\u4e00\u4e2a\u4f2a\u5143\u7d20\uff0c\u56e0\u4e3a<code>::before<\/code>\u7684\u5c3a\u5bf8\u9ad8\u5ea6\u88ab\u9650\u5236\u5728\u4e861px, \u6b64\u65f6\u53ea\u80fd<code>::after<\/code>\u4f2a\u5143\u7d20\u51fa\u9a6c\uff0c\u540c\u6837\u4e0d\u5c55\u793a\u4e00\u81f4\u7684CSS\u4ee3\u7801\u3002<\/p>\n<pre>&lt;hr class=\"hr-mid-border-content\" data-content=\"\u5206\u9694\u7ebf\"&gt;<\/pre>\n<pre>.hr-mid-border-content::after{\r\n    content: attr(data-content);\r\n    position: absolute;\r\n    padding: 4px 1ch;\r\n    top: 50%; left: 50%;\r\n    transform: translate(-50%, -50%);\r\n    color: transparent;\r\n    border: 1px solid #d0d0d5;\r\n}<\/pre>\n<p>\u6548\u679c\u5c31\u662f\u9171\u6837\u5b50\u6ef4\uff1a<\/p>\n<hr class=\"hr-mid-border-content\" data-content=\"\u5206\u9694\u7ebf\" style=\"line-height:1.2;\">\n<h3>\u56db\u3001\u4e13\u95e8\u5f04\u4e86\u4e2a\u9879\u76ee\u5f00\u6e90\u4e86<\/h3>\n<p>\u4e00\u4e2a\u4eba\u518d\u600e\u4e48\u60f3\u7834\u8111\u888b\uff0c\u6240\u80fd\u5b9e\u73b0\u7684\u4e14\u5b9e\u7528\u7684\u5206\u9694\u7ebf\u6548\u679c\u4e5f\u662f\u6709\u9650\u7684\uff0c\u6b64\u65f6\uff0c\u5c31\u9700\u8981\u5927\u5bb6\u7684\u667a\u6167\u4e86\u3002<\/p>\n<p>\u56e0\u6b64\uff0c\u6211\u4e13\u95e8\u5728gitee\u4e0a\u628a\u76f8\u5173CSS\u4ee3\u7801\u90fd\u5f00\u6e90\u51fa\u53bb\u4e86\u3002<\/p>\n<p>\u9879\u76ee\u5730\u5740\u662f\uff1a<a href=\"https:\/\/gitee.com\/zhangxinxu\/css-hr\" rel=\"noopener\" target=\"_blank\">https:\/\/gitee.com\/zhangxinxu\/css-hr<\/a><\/p>\n<p>\u4ed3\u5e93\u622a\u56fe\u793a\u610f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202105\/2021-05-30_003511.png\" width=\"559\" height=\"394\" alt=\"\u4ed3\u5e93\u622a\u56fe\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u6b22\u8fce\u5927\u5bb6\u8d21\u732e\u5176\u4ed6\u7cbe\u5f69\u7684\u5206\u9694\u7ebf\u6548\u679c\u3002<\/p>\n<p>\u4e5f\u6b22\u8fce\u5927\u5bb6\u5173\u6ce8\u6211\u7684gitee\u8d26\u6237\uff0c\u4ee5\u540e\u7c7b\u4f3c\u7684\u5c0f\u9879\u76ee\u90fd\u4f1a\u53d1\u5e03\u5728gitee\u4e0a\uff0c\u901f\u5ea6\u5feb\uff0c\u4f53\u9a8c\u597d\u3002<\/p>\n<p>OK\uff0c\u4ee5\u4e0a\u5c31\u662f\u672c\u6587\u5168\u90e8\u5185\u5bb9\uff0c\u5982\u679c\u60a8\u89c9\u5f97\u76f8\u5173\u5185\u5bb9\u8fd8\u4e0d\u9519\uff0c\u6b22\u8fce\u8f6c\u53d1\u3001\u6b22\u8fce\u5206\u4eab\u3001\u6b22\u8fce\u70b9\u8d5e\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/2764.svg\" width=\"20\" height=\"20\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u6b22\u8fce\u5206\u4eab\uff0c\u52ff\u5168\u6587\u8f6c\u8f7d\uff0c\u5982\u679c\u5b9e\u5728\u559c\u6b22\uff0c\u53ef\u6536\u85cf\uff0c\u6c38\u4e0d\u8fc7\u671f\uff0c\u4e14\u4f1a\u53ca\u65f6\u66f4\u65b0\u77e5\u8bc6\u70b9\u53ca\u4fee\u6b63\u9519\u8bef\uff0c\u9605\u8bfb\u4f53\u9a8c\u4e5f\u66f4\u597d\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=9962\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=9962<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202105\/css-hr-cover.png\" width=\"160\" height=\"102\" alt=\"\u8349\u6ce5\u9a6c \u7b80\u7b14\u753b html hr\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u672c\u6587\u5c55\u793a\u5927\u91cf\u4f7f\u7528HTML hr\u6807\u7b7e\u5b9e\u73b0\u7684\u5206\u9694\u7ebf\u6548\u679c\uff0c\u8bed\u4e49\u597d\uff0c\u6548\u679c\u4e5f\u597d\uff0c\u76f4\u63a5\u590d\u5236\u7c98\u8d34\u5c31\u80fd\u4f7f\u7528\uff0c\u8fdb\u6765\u770b\u770bCSS + hr\u6807\u7b7e\u80fd\u73a9\u51fa\u4ec0\u4e48\u82b1\u5427~<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,1097],"tags":[298,1759,9,1183,1181,1760,1585,428,391],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/9962"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=9962"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/9962\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=9962"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=9962"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=9962"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}