{"id":2378,"date":"2017-11-30T14:41:41","date_gmt":"2017-11-30T06:41:41","guid":{"rendered":"http:\/\/www.xttblog.com\/?p=2378"},"modified":"2017-11-30T14:41:41","modified_gmt":"2017-11-30T06:41:41","slug":"%e4%bd%bf%e7%94%a8clip-path%e5%ae%9e%e7%8e%b0%e4%bb%bb%e6%84%8f%e5%85%83%e7%b4%a0%e7%9a%84%e7%a2%8e%e7%89%87%e9%a3%9e%e5%85%a5%e5%8a%a8%e7%94%bb%e6%95%88%e6%9e%9c","status":"publish","type":"post","link":"https:\/\/www.xttblog.com\/?p=2378","title":{"rendered":"\u4f7f\u7528clip-path\u5b9e\u73b0\u4efb\u610f\u5143\u7d20\u7684\u788e\u7247\u98de\u5165\u52a8\u753b\u6548\u679c"},"content":{"rendered":"<p>\n\tclip-path \u662f<a href=\"https:\/\/www.xttblog.com\/?tag=css3\" name=\"css3\" target=\"_blank\" title=\"css3\">CSS3<\/a> \u4e2d\u7684\u4e00\u4e2a\u5c5e\u6027\u3002\u8be5\u5c5e\u6027\u53ef\u4ee5\u9632\u6b62\u90e8\u5206\u5143\u7d20\u901a\u8fc7\u5b9a\u4e49\u7684\u526a\u5207\u533a\u57df\u6765\u663e\u793a\uff0c\u4ec5\u901a\u8fc7\u663e\u793a\u7684\u7279\u6b8a\u533a\u57df\u3002\u526a\u5207\u533a\u57df\u662f\u88abURL\u5b9a\u4e49\u7684\u8def\u5f84\u4ee3\u66ff\u884c\u5185\u6216\u8005\u5916\u90e8<a href=\"https:\/\/www.xttblog.com\/?tag=SVG\" name=\"SVG\" target=\"_blank\" title=\"SVG\">svg<\/a>\uff0c\u6216\u8005\u5b9a\u4e49\u8def\u7ebf\u7684\u65b9\u6cd5\u4f8b\u5982circle()\u3002clip-path\u5c5e\u6027\u4ee3\u66ff\u4e86\u73b0\u5728\u5df2\u7ecf\u5f03\u7528\u7684\u526a\u5207&nbsp;clip\u5c5e\u6027\u3002\n<\/p>\n<p>\n\tclip-path\u4e4b\u6240\u4ee5\u6ca1\u6709\u5f88\u666e\u53ca\uff0c\u662f\u56e0\u4e3a\u5176\u6d4f\u89c8\u5668\u517c\u5bb9\u95ee\u9898\u3002\u5f88\u591aIE\u6d4f\u89c8\u5668\u5bf9\u9f50\u5c5e\u6027\u4e0d\u662f\u5f88\u652f\u6301\u3002\u6211\u4eec\u770b\u4e0b\u4ed6\u7684\u6d4f\u89c8\u5668\u517c\u5bb9\uff1a\n<\/p>\n<p>\n\t<img decoding=\"async\" alt=\"clip-path \u6d4f\u89c8\u5668\u517c\u5bb9\u6027\" src=\"http:\/\/img.bbs.csdn.net\/upload\/201711\/30\/1512022948_915518.png\" style=\"width: 700px;height: 324px\" \/>\n<\/p>\n<p>\n\tIE\u5b8c\u5168\u4e0d\u652f\u6301\uff0c\u5c3d\u91cf\u4f7f\u7528webkit\u5185\u6838\uff0c\u9700\u8981\u52a0\u4e0a\u5185\u6838\u524d\u7f00-webkit-\u3002\n<\/p>\n<h2>\n\tclip-path \u8bed\u6cd5<br \/>\n<\/h2>\n<p>\n\t\u5173\u4e8e clip-path \u8bed\u6cd5\u4ecb\u7ecd\u7684\u6587\u7ae0\u4e0d\u662f\u5f88\u591a\uff0c\u6211\u8fd9\u91cc\u8d34\u4e00\u4e2a\u603b\u7ed3\u3002\n<\/p>\n<pre class=\"brush:css;\">\r\nclip-path: none; \r\nclip-path: url(resources.svg#c1);\r\nclip-path: fill-box;\r\nclip-path: stroke-box;\r\nclip-path: view-box;\r\nclip-path: margin-box\r\nclip-path: border-box\r\nclip-path: padding-box\r\nclip-path: content-box\r\nclip-path: inset(100px 50px);\r\nclip-path: circle(50px at 0 100px);\r\nclip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);\r\nclip-path: padding-box circle(50px at 0 100px);\r\nclip-path: inherit;\r\nclip-path: initial;\r\nclip-path: unset;<\/pre>\n<h2>\n\t\u90e8\u5206\u53c2\u6570\u89e3\u91ca<br \/>\n<\/h2>\n<ul>\n<li>\n\t\turl()\uff1a\u4ee3\u8868\u526a\u5207\u5143\u7d20\u7684\u8def\u5f84\n\t<\/li>\n<li>\n\t\tinset(), circle(), ellipse(), polygon()\uff1a\u4e00\u4e2a &lt;basic-shape&gt; \u65b9\u6cd5. \u8fd9\u79cd\u5f62\u72b6\u5c06\u4f1a\u5229\u7528\u6307\u5b9a\u7684&lt;geometry-box&gt;\u6765\u5b9a\u4f4d\u548c\u56fa\u5b9a\u57fa\u672c\u5f62\u72b6\u3002\u5982\u679c\u6ca1\u6709geometry box\uff08\u51e0\u4f55\u76d2\u6a21\u578b\uff09\u7279\u522b\u6307\u51fa\u7684\u8bdd\uff0cborder-box\u5c06\u4f1a\u662f\u9ed8\u8ba4\u7684\u76d2\u6a21\u578b\u3002\n\t<\/li>\n<li>\n\t\t&lt;geometry-box&gt;\u5982\u679c\u540c&lt;basic-shape&gt;\u4e00\u8d77\u58f0\u660e\uff0c\u5b83\u5c06\u4e3a\u57fa\u672c\u5f62\u72b6\u63d0\u4f9b\u76f8\u5e94\u7684\u53c2\u8003\u76d2\u5b50\u3002\u901a\u8fc7\u81ea\u5b9a\u4e49\uff0c\u5b83\u5c06\u5229\u7528\u786e\u5b9a\u7684\u76d2\u5b50\u8fb9\u7f18\u5305\u62ec\u4efb\u4f55\u5f62\u72b6\u8fb9\u89d2\uff08\u6bd4\u5982\u8bf4\uff0c\u88abborder-radius\u5b9a\u4e49\u7684\u526a\u5207\u8def\u5f84\uff09\u3002\u51e0\u4f55\u4f53\u76d2\u5b50\u5c06\u4f1a\u6709\u4ee5\u4e0b\u7684\u503c\uff1a<br \/>\n\t\tfill-box<br \/>\n\t\t\u5229\u7528\u5bf9\u8c61\u8fb9\u754c\u6846\u4f5c\u4e3a\u5f15\u7528\u6846\u3002<br \/>\n\t\tstroke-box<br \/>\n\t\t\u4f7f\u7528\u7b14\u89e6\u8fb9\u754c\u6846\u4f5c\u4e3a\u5f15\u7528\u6846<br \/>\n\t\tview-box<br \/>\n\t\t\u4f7f\u7528\u6700\u8fd1\u7684SVG\u89c6\u53e3\u4f5c\u4e3a\u5f15\u7528\u6846\u3002\u5982\u679cviewBox \u5c5e\u6027\u88ab\u6307\u5b9a\u6765\u4e3a\u5143\u7d20\u521b\u5efaSVG\u89c6\u53e3\uff0c\u5f15\u7528\u6846\u5c06\u4f1a\u88ab\u5b9a\u4f4d\u5728\u5750\u6807\u7cfb\u7684\u539f\u70b9\uff0c\u5f15\u7528\u6846\u4f4d\u4e8e\u7531view-box\u5c5e\u6027\u5efa\u7acb\u7684\u5750\u6807\u7cfb\u7684\u539f\u70b9\uff0c\u5f15\u7528\u6846\u7684\u5c3a\u5bf8\u7528\u6765\u8bbe\u7f6eviewbox\u5c5e\u6027\u7684\u5bbd\u9ad8\u503c\u3002<br \/>\n\t\tmargin-box<br \/>\n\t\t\u4f7f\u7528 margin box \u4f5c\u4e3a\u5f15\u7528\u6846<br \/>\n\t\tborder-box<br \/>\n\t\t\u4f7f\u7528 border box \u4f5c\u4e3a\u5f15\u7528\u6846.<br \/>\n\t\tpadding-box<br \/>\n\t\t\u4f7f\u7528 padding box \u4f5c\u4e3a\u5f15\u7528\u6846.<br \/>\n\t\tcontent-box<br \/>\n\t\t\u4f7f\u7528 content box \u4f5c\u4e3a\u5f15\u7528\u6846\n\t<\/li>\n<li>\n\t\tnone\uff1a\u8fd9\u91cc\u6ca1\u6709\u521b\u5efa\u7684\u526a\u5207\u8def\u5f84\u3002\n\t<\/li>\n<\/ul>\n<h2>\n\t\u4f8b\u5b50<br \/>\n<\/h2>\n<p>\n\t\u4e0b\u9762\u6211\u4eec\u6765\u5b9e\u73b0\u672c\u6587\u6807\u9898\u6240\u8bf4\u7684\u4f7f\u7528clip-path\u5b9e\u73b0\u4efb\u610f\u5143\u7d20\u7684\u788e\u7247\u98de\u5165\u52a8\u753b\u6548\u679c\u7684\u6848\u4f8b\u5b9e\u73b0\u3002\n<\/p>\n<p>\n\t\u9996\u5148\u662f\u7f16\u5199HTML\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:xml;\">\r\n&lt;strong&gt;1. \u666e\u901a\u5e26\u6587\u672c\u7684\u5143\u7d20&lt;\/strong&gt;\r\n&lt;div class=&quot;box active&quot;&gt;\r\n    &lt;p id=&quot;text&quot; class=&quot;text clip&quot;&gt;\u9b54\u517d\u8981\u4e0a\u6620\u4e86...&lt;\/p&gt;\r\n&lt;\/div&gt;\r\n&lt;strong&gt;2. \u66ff\u6362\u5143\u7d20\u5982\u56fe\u7247&lt;\/strong&gt;\r\n&lt;div class=&quot;box active&quot;&gt;\r\n    &lt;img id=&quot;image&quot; class=&quot;image clip&quot; src=&quot;http:\/\/www.xttblog.com\/image\/xxxx.jpg&quot;&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>\n\t\u63a5\u7740\u662f<a href=\"https:\/\/www.xttblog.com\/?tag=css3\" name=\"css3\" target=\"_blank\" title=\"css3\">CSS3<\/a>\u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:css;\">\r\n.clip[style] {\r\n    opacity: 0;\r\n}\r\n.active .clip:not([style]) {\r\n    opacity: 0;\r\n    animation: fadeIn .1s .4s both;\r\n}\r\n.active .clip[style] {\r\n    will-change: transform;\r\n    animation: noTransform .5s both;\r\n}\r\n@keyframes noTransform {\r\n    to {\r\n        opacity: 1;\r\n        transform: translate3d(0, 0, 0) rotate(0);\r\n    }\r\n}\r\n@keyframes fadeIn {\r\n  from { opacity: 0; }\r\n  to { opacity: 1; }\r\n}\r\n.box { height: 190px; }\r\n.text { position: absolute; width: 300px; }\r\n.image { position: absolute; }<\/pre>\n<p>\n\t\u6700\u540e\u662f<a href=\"https:\/\/www.xttblog.com\/?tag=javascript\" name=\"JavaScript\" target=\"_blank\" title=\"JavaScript\">JavaScript<\/a> \u4ee3\u7801\uff1a\n<\/p>\n<pre class=\"brush:jscript;\">\r\nvar eleText = document.getElementById(&#039;text&#039;),\r\n\teleImage = document.getElementById(&#039;image&#039;);\r\n\/\/ \u7236\u7ea7\u5143\u7d20\r\nvar eleParentText = eleText.parentNode,\r\n\teleParentImage = eleImage.parentNode;\r\nvar eleBtnText = document.getElementById(&#039;playText&#039;),\r\n\teleBtnImage = document.getElementById(&#039;playImage&#039;);\r\nvar isSupport = \r\n\/\/ \u788e\u7247\u7279\u6548\u521d\u59cb\u5316\r\nclipPath(eleText);\r\nclipPath(eleImage);\r\n\/\/ \u70b9\u51fb\u64ad\u653e\r\nif (isSupport) {\r\n\teleBtnText.onclick = function() {\r\n\t\teleParentText.classList.remove(&#039;active&#039;);\t\r\n\t\teleParentText.offsetHeight;\r\n\t\teleParentText.classList.add(&#039;active&#039;);\r\n\t};\t\r\n\teleBtnImage.onclick = function() {\r\n\t\teleParentImage.classList.remove(&#039;active&#039;);\t\r\n\t\teleParentImage.offsetHeight;\r\n\t\teleParentImage.classList.add(&#039;active&#039;);\r\n\t};\t\r\n}<\/pre>\n<p>\n\t\u6587\u4e2d\u7528\u5230\u7684clipPath\u65b9\u6cd5\u5df2\u88ab\u5df2\u88ab\u6211\u5171\u4eab\u5230\u4e86github\uff0c\u4e0b\u8f7d\u5730\u5740\u662f\uff1a<a href=\"https:\/\/github.com\/xmt1139057136\/clipPath-min.js\" name=\"clipPath-min.js\" target=\"_blank\" title=\"clipPath-min.js\">https:\/\/github.com\/xmt1139057136\/clipPath-min.js<\/a>\u3002\n<\/p>\n<h2>\n\t\u53c2\u8003\u8d44\u6599<br \/>\n<\/h2>\n<ul>\n<li>\n\t\t<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/clip-path\" name=\"clip-path\" target=\"_blank\" title=\"clip-path\">clip-path<\/a>\n\t<\/li>\n<li>\n\t\t<a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/SVG\/Element\/clipPath\" name=\"&lt;clipPath&gt;\" target=\"_blank\" title=\"&lt;clipPath&gt;\">&lt;clipPath&gt;<\/a>\n\t<\/li>\n<\/ul>\n<!-- <audio autoplay=\"autoplay\" height=\"100\" width=\"100\" hidden=\"true\"><source src=\"https:\/\/c.coka.la\/orAvPR.mp3\" type=\"audio\/mp3\"\/><\/audio><img decoding=\"async\" src=\"https:\/\/images.weserv.nl\/?url=https:\/\/ws3.sinaimg.cn\/large\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/> --><p><!-- <img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/xmt1139057136\/xttblog\/master\/8fa5dcfcgy1g4em3rzar5j20ib089ae0.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/>--><img decoding=\"async\" src=\"https:\/\/saas.51autoparts.cn\/api\/admin\/sys-file\/oss\/file?fileName=84db51f8561e448f9a4fda2eff0811f9.jpg\" alt=\"\u4e1a\u4f59\u8349\u516c\u4f17\u53f7\"\/><\/p><p>\u6700\u540e\uff0c\u6b22\u8fce\u5173\u6ce8\u6211\u7684\u4e2a\u4eba\u5fae\u4fe1\u516c\u4f17\u53f7\uff1a\u4e1a\u4f59\u8349\uff08yyucao\uff09\uff01<b>\u53ef\u52a0\u4f5c\u8005\u5fae\u4fe1\u53f7\uff1a<font color=\"red\">xttblog2<\/font>\u3002\u5907\u6ce8\uff1a\u201c1\u201d\uff0c\u6dfb\u52a0\u535a\u4e3b\u5fae\u4fe1\u62c9\u4f60\u8fdb\u5fae\u4fe1\u7fa4\u3002\u5907\u6ce8\u9519\u8bef\u4e0d\u4f1a\u540c\u610f\u597d\u53cb\u7533\u8bf7\u3002<\/b>\u518d\u6b21\u611f\u8c22\u60a8\u7684\u5173\u6ce8\uff01\u540e\u7eed\u6709\u7cbe\u5f69\u5185\u5bb9\u4f1a\u7b2c\u4e00\u65f6\u95f4\u53d1\u7ed9\u60a8\uff01\u539f\u521b\u6587\u7ae0\u6295\u7a3f\u8bf7\u53d1\u9001\u81f3532009913@qq.com\u90ae\u7bb1\u3002\u5546\u52a1\u5408\u4f5c\u4e5f\u53ef\u6dfb\u52a0\u4f5c\u8005\u5fae\u4fe1\u8fdb\u884c\u8054\u7cfb\uff01<\/p><p>\u672c\u6587\u539f\u6587\u51fa\u5904\uff1a<a href=\"https:\/\/www.xttblog.com\">\u4e1a\u4f59\u8349<\/a>\uff1a &raquo; <a href=\"https:\/\/www.xttblog.com\/?p=2378\">\u4f7f\u7528clip-path\u5b9e\u73b0\u4efb\u610f\u5143\u7d20\u7684\u788e\u7247\u98de\u5165\u52a8\u753b\u6548\u679c<\/a><\/p><!-- <div class=\"bd-reward-stl\"><button id=\"bdRewardBtn\"><span><\/span><\/button><\/div> -->","protected":false},"excerpt":{"rendered":"<p>clip-path \u662fCSS3 \u4e2d\u7684\u4e00\u4e2a\u5c5e\u6027\u3002\u8be5\u5c5e\u6027\u53ef\u4ee5\u9632\u6b62\u90e8\u5206\u5143\u7d20\u901a\u8fc7\u5b9a\u4e49\u7684\u526a\u5207\u533a\u57df\u6765\u663e\u793a\uff0c\u4ec5\u901a\u8fc7\u663e\u793a\u7684\u7279\u6b8a [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[814,1106,52],"class_list":["post-2378","post","type-post","status-publish","format-standard","hentry","category-html5","tag-css3","tag-javascript","tag-svg"],"_links":{"self":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2378","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2378"}],"version-history":[{"count":1,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2378\/revisions"}],"predecessor-version":[{"id":2379,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=\/wp\/v2\/posts\/2378\/revisions\/2379"}],"wp:attachment":[{"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2378"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2378"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.xttblog.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2378"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}