{"id":9328,"date":"2020-03-18T16:56:03","date_gmt":"2020-03-18T08:56:03","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=9328"},"modified":"2020-03-18T16:56:03","modified_gmt":"2020-03-18T08:56:03","slug":"css-overflow-wrap-anywhere","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2020\/03\/css-overflow-wrap-anywhere\/","title":{"rendered":"CSS overflow-wrap\u65b0\u5c5e\u6027\u503canywhere\u662f\u5e72\u561b\u7528\u7684\uff1f"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=9328\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=9328<\/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\/202003-anywhere.jpg';<\/script><\/p>\n<h3>\u4e00\u3001\u5148\u4e86\u89e3\u4e0boverflow-wrap\u5c5e\u6027<\/h3>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202003\/anywhere-cover.jpg\" width=\"160\" height=\"111\" class=\"alignleft size-medium\" \/><\/p>\n<p>CSS <code>overflow-wrap<\/code>\u5c5e\u6027\u5176\u5b9e\u5c31\u662f\u4ee5\u524d\u7684<code>word-wrap<\/code>\u5c5e\u6027\uff0cMDN\u73b0\u5728\u76f4\u63a5\u628a<code>word-wrap<\/code>\u7684\u6587\u6863\u9875\u8df3\u8f6c\u5230<code>overflow-wrap<\/code>\u5c5e\u6027\u7684\u6587\u6863\u9875\u4e86\u3002<\/p>\n<p>\u7531\u4e8e<code>overflow-wrap<\/code>\u5c5e\u6027IE\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\uff0c\u800c\u5176\u4ed6\u73b0\u4ee3\u6d4f\u89c8\u5668\u4f9d\u7136\u652f\u6301\u8001\u7684<code>word-wrap<\/code>\u5c5e\u6027\u8bed\u6cd5\uff0c\u56e0\u6b64\uff0c\u6ca1\u6709\u4efb\u4f55\u7406\u7531\u4f7f\u7528<code>overflow-wrap<\/code>\u5c5e\u6027\u3002<\/p>\n<p>\u76f4\u5230\u6709\u4e00\u5929<code>overflow-wrap<\/code>\u5c5e\u6027\u7a81\u7136\u652f\u6301\u4e86\u4e00\u4e2a\u65b0\u7684\u5c5e\u6027\u503c<code>anywhere<\/code>\uff0c<code>overflow-wrap<\/code>\u5c5e\u6027\u5c31\u6709\u4e86\u4f7f\u7528\u7684\u7406\u7531\u4e86\u3002<\/p>\n<p><code>overflow-wrap<\/code>\u5c5e\u6027\u7684\u6b63\u5f0f\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre>overflow-wrap: normal | break-word | anywhere<\/pre>\n<h3>\u4e8c\u3001anywhere\u6709\u4ec0\u4e48\u7528<\/h3>\n<p>\u5728\u5c55\u5f00\u6280\u672f\u5c5e\u6027\u503c<code>anywhere<\/code>\u7684\u4f5c\u7528\u4e4b\u524d\uff0c\u5148\u7ed9\u5927\u5bb6\u79d1\u666e\u4e00\u4e2a\u6982\u5ff5\uff0c\u5173\u4e8e\u201c\u786c\u6362\u884c\u201d\u548c\u201c\u8f6f\u6362\u884c\u201d\u3002<\/p>\n<p>\u786c\u6362\u884c\u5728\u6587\u672c\u7684\u6362\u884c\u70b9\u5904\u63d2\u5165\u4e86\u5b9e\u9645\u6362\u884c\u7b26\uff0c\u800c\u8f6f\u6362\u884c\u7684\u6587\u672c\u5b9e\u9645\u4e0a\u4ecd\u5728\u540c\u4e00\u884c\uff0c\u4f46\u770b\u8d77\u6765\u5b83\u88ab\u5206\u6210\u4e86\u51e0\u884c\uff0c\u4f8b\u5982<code>word-break:break-all<\/code>\u8ba9\u957f\u82f1\u6587\u5355\u8bcd\u5c31\u5c5e\u4e8e\u8f6f\u6362\u884c\u3002<\/p>\n<h4>anywhere\u548cbreak-word\u7684\u5f02\u540c<\/h4>\n<p>\u5728\u6b63\u5e38\u72b6\u6001\u4e0b\uff0c<code>anywhere<\/code>\u548c<code>break-word<\/code>\u7684\u8868\u73b0\u662f\u4e00\u6837\u7684\uff0c\u5373\u5982\u679c\u884c\u4e2d\u6ca1\u6709\u5176\u4ed6\u53ef\u63a5\u53d7\u7684\u65ad\u70b9\uff0c\u5219\u53ef\u4ee5\u5728\u4efb\u4f55\u70b9\u65ad\u5f00\u539f\u672c\u4e0d\u53ef\u65ad\u5f00\u7684\u5b57\u7b26\u4e32\uff08\u5982\u957f\u5355\u8bcd\u6216URL\uff09\uff0c\u5e76\u4e14\u5728\u65ad\u70b9\u5904\u4e0d\u63d2\u5165\u8fde\u5b57\u7b26\u3002<\/p>\n<p>\u7528\u4eba\u8bdd\u89e3\u91ca\u5c31\u662f\u8fde\u7eed\u7684\u82f1\u6587\u5b57\u7b26\u5982\u679c\u53ef\u4ee5\u4e0d\u7528\u65ad\u5c31\u4e0d\u65ad\uff0c\u5982\u679c\u5b9e\u5728\u4e0d\u884c\uff0c\u5c31\u65ad\u5f00\uff0c\u56e0\u6b64\u76f8\u6bd4break-all\u53ef\u80fd\u4f1a\u7559\u767d\u3002\u5982\u4e0b\u56fe\u6240\u793a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202003\/2020-03-18_161120.png\" width=\"345\" height=\"230\" alt=\"\u7559\u767d\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u5177\u4f53\u53ef\u53c2\u89c1\u8fd9\u7bc7\u6587\u7ae0\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=5061\">word-break:break-all\u548cword-wrap:break-word\u7684\u533a\u522b<\/a>\u201d\u3002<\/p>\n<p>\u4e0b\u9762\u8bb2\u4e0b\u4e0d\u540c\u652f\u6301\uff0c<code>anywhere<\/code>\u548c<code>break-word<\/code>\u7684\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\uff0c\u5728<code>overflow-wrap:anywhere<\/code>\u8ba1\u7b97\u6700\u5c0f\u5185\u5bb9\u5c3a\u5bf8\u7684\u65f6\u5019\u4f1a\u8003\u8651\u8f6f\u6362\u884c\uff0c\u800c<code>overflow-wrap:break-word<\/code>\u4e0d\u4f1a\u8003\u8651\u8f6f\u6362\u884c\u3002<\/p>\n<p>\u4f8b\u5982\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>&lt;p class=\"anywhere\"&gt;I'm zhangxinxu.&lt;\/p&gt;\r\n&lt;p class=\"break-word\"&gt;I'm zhangxinxu.&lt;\/p&gt;<\/pre>\n<pre>p {\r\n    display: inline-block;\r\n    width: min-content;\r\n    padding: 10px;\r\n    border: solid deepskyblue;\r\n    vertical-align: top;\r\n}\r\n.anywhere {\r\n    overflow-wrap: anywhere;  \r\n}\r\n.break-word {\r\n    overflow-wrap: break-word;\r\n}<\/pre>\n<p>\u7ed3\u679c\u5728Chrome\u6d4f\u89c8\u5668\u4e0b\u7684\u6548\u679c\u5c31\u50cf\u4e0b\u56fe\u8fd9\u6837\uff1a<br \/>\n<img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202003\/3-66_anywhere.png\" loading=\"lazy\" width=\"149\" height=\"246\"><\/p>\n<p>\u53ef\u4ee5\u770b\u5230\uff0c\u5e94\u7528\u4e86<code>overflow-wrap:anywhere<\/code>\u58f0\u660e\u7684\u5143\u7d20\u7684\u6700\u5c0f\u5bbd\u5ea6\u662f\u628a\u6bcf\u4e00\u4e2a\u82f1\u6587\u5355\u8bcd\u90fd\u7834\u5f00\u540e\u7684\u5bbd\u5ea6\uff0c\u800c\u5e94\u7528\u4e86<code>overflow-wrap:break-word<\/code>\u58f0\u660e\u7684\u5143\u7d20\u8fd8\u662f\u6309\u7167\u9ed8\u8ba4\u7684\u6700\u5c0f\u5bbd\u5ea6\u89c4\u5219\u8fdb\u884c\u8ba1\u7b97\u3002<\/p>\n<p>\u6709\u6b64\u53ef\u89c1\uff0c<code>overflow-wrap:anywhere<\/code>\u5c31\u50cf\u662f<code>overflow-wrap:break-word<\/code>\u548c<code>word-break:break-all<\/code>\u58f0\u660e\u7684\u6df7\u5408\u4f53\uff0c\u4e3b\u8981\u7528\u5728\u5f39\u6027\u5e03\u5c40\u4e2d\uff0c\u5373\u5143\u7d20\u5c3a\u5bf8\u8db3\u591f\u7684\u65f6\u5019\u5355\u8bcd\u5c3d\u91cf\u5b8c\u6210\u663e\u793a\uff0c\u4e0d\u968f\u4fbf\u4e2d\u65ad\uff0c\u5982\u679c\u5c3a\u5bf8\u4e0d\u591f\uff0c\u90a3\u5c31\u80fd\u65ad\u5219\u65ad\u3002<\/p>\n<h3>\u4e09\u3001\u517c\u5bb9\u6027\u548c\u7ed3\u8bed<\/h3>\n<p><code>overflow-wrap:anywhere<\/code>\u58f0\u660e\u76ee\u524d\u517c\u5bb9\u6027\u8fd8\u4e0d\u7b97\u4e50\u89c2\uff0c\u76ee\u524d\uff082020\u5e743\u6708\uff09Safari\u6d4f\u89c8\u5668\u8fd8\u4e0d\u652f\u6301\uff0cChrome\u6d4f\u89c8\u5668\u4e5f\u662f\u521a\u521a\u652f\u6301\uff0c\u5177\u4f53\u4fe1\u606f\u53c2\u89c1\u8868\uff1a<\/p>\n<table class=\"params_table\" cellspacing=\"1\">\n<caption><small><codeanywhere<\/code>\u7684\u517c\u5bb9\u6027\uff08\u6570\u636e\u6e90\u81eaMDN\uff09<\/small><\/caption>\n<thead>\n<tr>\n<th><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/study\/browser\/ie.png\" loading=\"lazy\" width=\"32\" height=\"32\" alt=\"Internet Explorer logo\"><br \/>IE<\/th>\n<th><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/study\/browser\/edge.png\" loading=\"lazy\" width=\"32\" height=\"32\" alt=\"Edge logo\"><br \/>Edge<\/th>\n<th><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/study\/browser\/firefox.png\" loading=\"lazy\" width=\"32\" height=\"32\" alt=\"Firefox logo\"><br \/>Firefox<\/th>\n<th><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/study\/browser\/chrome.png\" loading=\"lazy\" width=\"32\" height=\"32\" alt=\"Chrome logo\"><br \/>Chrome<\/th>\n<th><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/study\/browser\/safari.png\" loading=\"lazy\" width=\"32\" height=\"32\" alt=\"Safari logo\"><br \/>Safari<\/th>\n<th><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/study\/browser\/safari.png\" loading=\"lazy\" width=\"32\" height=\"32\" alt=\"Safari logo\"><br \/>iOS<br \/>Safari<\/th>\n<th><img decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/study\/browser\/android.png\" loading=\"lazy\" width=\"32\" height=\"32\" alt=\"Android Browser logo\"><br \/>Android<br \/>Browser<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr align=\"center\">\n<td><span class=\"red\">\u2718<\/span><\/td>\n<td><span class=\"red\">\u2718<\/span><\/td>\n<td>65+ <span class=\"green\">\u2714<\/span><\/td>\n<td>80+ <span class=\"green\">\u2714<\/span><\/td>\n<td>13+ <span class=\"red\">\u2718<\/span><\/td>\n<td>13.3+ <span class=\"red\">\u2718<\/span><\/td>\n<td>80+ <span class=\"green\">\u2714<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u56e0\u6b64\u76ee\u524d\u8fd8\u4e0d\u9002\u5408\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\u4f7f\u7528\uff0c\u5927\u5bb6\u4e86\u89e3\u5373\u53ef\u3002<\/p>\n<p>\u800c\u4e14\uff0c\u5e38\u89c4\u7684\u6587\u5b57\u6392\u7248\u5927\u5bb6\u4e5f\u4e0d\u4f1a\u7528\u5230\u8fd9\u4e2a\u5c5e\u6027\uff0c\u5c31\u7b97\u77e5\u9053\u8fd9\u4e2a\u5c5e\u6027\u503c\uff0c\u4e5f\u4e0d\u4f1a\u60f3\u5230\u4f7f\u7528\u3002<\/p>\n<p>\u6ce8\u5b9a\u662f\u4e00\u4e2a\u65e5\u540e\u88ab\u4eba\u9057\u5fd8\u7684CSS\u7279\u6027\u3002<\/p>\n<p>\u5c31\u8bf4\u8fd9\u4e48\u591a\uff0c\u5e26\u5927\u5bb6\u7b80\u5355\u4e86\u89e3\u4e00\u4e2a\u65b0\u7279\u6027\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/1f60e.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=9328\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=9328<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/202003\/anywhere-cover.jpg\" width=\"160\" height=\"111\" class=\"alignright size-medium\" loading=\"lazy\" \/><\/p>\n<p>\u5148\u4ecb\u7ecdoverflow-wrap\u5c5e\u6027\uff0c\u518d\u4ecb\u7ecdoverflow-wrap\u65b0\u51fa\u4e86\u4e00\u4e2a\u5c5e\u6027\u503canywhere\uff0c\u8bf4\u4e0d\u5b9a\u5728\u4ee5\u540e\u6587\u5b57\u6392\u7248\u5e03\u5c40\u65f6\u5019\u7528\u5f97\u4e0a\u3002<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[1583,1029,1584,1271,1030,1028,1582,675],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/9328"}],"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=9328"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/9328\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=9328"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=9328"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=9328"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}