{"id":8592,"date":"2019-04-20T17:37:32","date_gmt":"2019-04-20T09:37:32","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=8592"},"modified":"2019-04-20T17:37:32","modified_gmt":"2019-04-20T09:37:32","slug":"css-parallelogram-layout","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2019\/04\/css-parallelogram-layout\/","title":{"rendered":"CSS\u5b9e\u73b0\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u6548\u679c"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=8592\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=8592<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4e2a\u4eba\u7f51\u7ad9\u65e0\u9700\u6388\u6743\uff0c\u4f46\u9700\u8981\u4fdd\u7559\u539f\u4f5c\u8005\u3001\u51fa\u5904\u4ee5\u53ca\u6587\u4e2d\u94fe\u63a5\uff0c\u4efb\u4f55\u7f51\u7ad9\u5747\u53ef\u6458\u8981\u805a\u5408\uff0c\u5546\u7528\u8bf7\u8054\u7cfb\u6388\u6743\u3002<br \/>\n<script>window.wxShareImgUrl = 'https:\/\/www.zhangxinxu.com\/study\/image\/share\/201904-shapes-thumb.jpg';<\/script><\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201904\/shapes-thumb-deal.png\" width=\"484\" height=\"300\" alt=\"\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u7f29\u7565\u56fe\" class=\"alignnone clip size-medium\" \/><\/p>\n<p>\u5982\u4f55\u5b9e\u73b0\u4e0b\u56fe\u6240\u793a\u7684\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u6548\u679c\uff1f<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201904\/2019-04-20_153921.png\" width=\"500\" height=\"272\" alt=\"\u5e73\u884c\u56db\u8fb9\u5f62\u6548\u679c\u793a\u610f\u622a\u56fe\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u4e00\u3001skewX\u7684\u5c40\u9650<\/h3>\n<p>\u4e00\u63d0\u5230\u5e73\u884c\u56db\u8fb9\u5f62\uff0c\u6761\u4ef6\u53cd\u5c04\u822c\u7684\u5c31\u4f1a\u60f3\u8d77CSS <code>transform<\/code>\u4e2d\u7684<code>skew()<\/code>\/<code>skewX()<\/code>\/<code>skewY()<\/code>\u65b9\u6cd5\uff0c\u53ef\u4ee5\u8ba9\u5143\u7d20\u659c\u5207\uff0c\u4ece\u800c\u5b9e\u73b0\u5e73\u884c\u56db\u8fb9\u5f62\u6548\u679c\uff0c\u4f8b\u5982\u4e0b\u56fe\u6240\u793a\u7684\u5e73\u884c\u56db\u8fb9\u5f62\u8f93\u5165\u6846\u6548\u679c\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201904\/input-name.gif\" width=\"219\" height=\"43\" alt=\"\u5e73\u884c\u56db\u8fb9\u5f62\u8f93\u5165\u6846\u793a\u610fgif\" class=\"alignnone size-medium\" \/><\/p>\n<p>HTML\u5982\u4e0b\uff1a<\/p>\n<pre>&lt;div class=\"input-x\"&gt;\r\n    &lt;input class=\"input\" placeholder=\"\u60a8\u7684\u59d3\u540d\"&gt;\r\n&lt;\/div&gt;<\/pre>\n<p>CSS\u5982\u4e0b\uff0c\u5f62\u72b6\u7684\u5173\u952e\u5c31\u662f\u4e0b\u9762\u7ea2\u8272\u9ad8\u4eae\u7684<code>transform:skewX(-10deg)<\/code>\uff1a<\/p>\n<pre>.input-x {\r\n    display: inline-block;\r\n    position: relative;\r\n    z-index: 0;\r\n}\r\n.input-x::before {\r\n    content: '';\r\n    position: absolute;\r\n    left: 0; top: 0; right: 0; bottom: 0;\r\n    border: 2px solid #ddd;\r\n    background-color: #fff;\r\n    border-radius: 4px;\r\n    <span style=\"color:#cd0000;\">transform: skewX(-10deg);<\/span>\r\n    z-index: -1;    \r\n}\r\n.input {\r\n    display: block;\r\n    padding: 8px 10px;\r\n    border: 0; background: none;\r\n}<\/pre>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/201904\/parallelogram-input-demo.php\" target=\"_blank\">CSS\u5e73\u884c\u56db\u8fb9\u5f62\u7684\u8f93\u5165\u6846demo<\/a><\/p>\n<hr>\n<p>\u7136\u800c\uff0c\u4e00\u5f00\u59cb\u7684\u5e03\u5c40\u4e0d\u4ec5\u540e\u9762\u7684\u767d\u8272\u80cc\u666f\u5f62\u6210\u5e73\u884c\u56db\u8fb9\u5f62\uff0c\u6574\u6bb5\u6587\u5b57\u5185\u5bb9\u4e5f\u6309\u7167\u5e73\u884c\u56db\u8fb9\u5f62\u7684\u683c\u5f0f\u8fdb\u884c\u4e86\u6392\u7248\uff0c\u5982\u679c\u6587\u5b57\u5185\u5bb9\u4e5f\u5e94\u7528<code>skewX<\/code>\uff0c\u6240\u6709\u6587\u5b57\u5185\u5bb9\u5c31\u4f1a\u8868\u73b0\u4e3a\u503e\u659c\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<div style=\"width:260px; padding: 10px;transform: skewX(-10deg);border:1px solid #ccc;border-radius:4px;\">\u6211\u662f\u4e00\u6bb5\u6587\u5b57\u5185\u5bb9\uff0c\u6211\u5e94\u7528\u4e86transform\u5c5e\u6027\u4e2d\u7684skewX\uff0c\u770b\u770b\u6211\u73b0\u5728\u7684\u8868\u73b0\u662f\u600e\u6837\u5b50\u7684\u2026\u2026<\/div>\n<p>\u6211\u4eec\u7684\u9884\u671f\u5e94\u8be5\u662f\u6587\u5b57\u90fd\u662f\u6b63\u7acb\u663e\u793a\uff0c\u800c\u4e0d\u662f\u8fd9\u6837\u5b50\u7684\u503e\u659c\u3002\u6211\u4eec\u53ef\u80fd\u7b2c\u4e00\u53cd\u5e94\u662f\u5bf9\u91cc\u9762\u7684\u6587\u5b57\u8fdb\u884c\u53cd\u5411\u7684<code>skewX<\/code>\uff0c\u4f46\u90a3\u9700\u8981\u5bf9\u6bcf\u4e00\u884c\u6587\u5b57\u5355\u72ec\u5904\u7406\uff0c\u6216\u8005\u5bf9\u6bcf\u4e00\u4e2a\u5b57\u7b26\u5355\u72ec\u8fdb\u884c\u5904\u7406\uff0c\u6210\u672c\u6709\u4e9b\u9ad8\uff0c\u4e0d\u592a\u5b9e\u9645\u3002<\/p>\n<p>\u8fd9\u5c31\u662f<code>skewX<\/code>\u65b9\u6cd5\u7684\u5c40\u9650\uff0c\u90a3\u6709\u6ca1\u6709\u4ec0\u4e48\u5176\u4ed6\u65b9\u6cd5\u53ef\u4ee5\u5b9e\u73b0\u5e73\u884c\u56db\u8fb9\u5f62\u7684\u5e03\u5c40\u6548\u679c\u5462\uff1f\u6709\uff0c\u53ef\u4ee5\u501f\u52a9CSS Shapes\u5e03\u5c40\u5b9e\u73b0\u3002<\/p>\n<h3>\u4e8c\u3001CSS Shapes\u5e03\u5c40\u4e0e\u4e09\u89d2<\/h3>\n<p>CSS Shapes\u5e03\u5c40\u5b8c\u6574\u6559\u7a0b\u53ef\u4ee5\u53c2\u89c1\u6211\u4e4b\u524d\u5199\u7684\u6587\u7ae0\uff1a\u201c<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2019\/02\/css-css3-shapes\/\">\u5199\u7ed9\u81ea\u5df1\u770b\u7684CSS shapes\u5e03\u5c40\u6559\u7a0b<\/a>\u201d\u3002<\/p>\n<p>\u7136\u800c\u4f60\u5c31\u7b97\u719f\u6089\u4e86CSS Shapes\u5e03\u5c40\u7684\u6bcf\u4e00\u4e2aCSS\u5c5e\u6027\uff0c\u8fd9\u91cc\u7684\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u6548\u679c\u4f60\u8fd8\u4e0d\u4e00\u5b9a\u4f1a\u5b9e\u73b0\u5f97\u51fa\u6765\uff0c\u56e0\u4e3a\u9700\u8981\u501f\u52a9\u4e00\u70b9\u9006\u5411\u601d\u7ef4\u3002<\/p>\n<p>CSS Shapes\u5b9e\u73b0\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u7684\u5173\u952e\u4e0d\u5728\u4e8e\u5e73\u884c\u56db\u8fb9\u5f62\u672c\u8eab\uff0c\u800c\u5728\u4e8e\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u4e24\u4e2a\u4e09\u89d2\u5f62\u3002<\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/201903\/css-idea\/layout-quadrangle.php?aside=0\" rel=\"noopener\" target=\"_blank\">CSS Shapes\u5b9e\u73b0\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40demo<\/a><\/p>\n<p>HTML\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<pre><span style=\"color:green;\">&lt;!-- \u5de6\u4e09\u89d2 --&gt;<\/span>\r\n&lt;div class=\"shape-left\"&gt;&lt;\/div&gt;\r\n<span style=\"color:green;\">&lt;!-- \u53f3\u4e09\u89d2 --&gt;<\/span>\r\n&lt;div class=\"shape-right\"&gt;&lt;\/div&gt;\r\n&lt;content class=\"content\"&gt;\r\n   ...\u5185\u5bb9...\r\n&lt;\/content&gt;<\/pre>\n<p>\u6211\u4eec\u67e5\u770b\u4e0b\u5e03\u5c40\u76d2\u5b50\uff0c\u53ef\u89c1\u7aef\u502a\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201904\/2019-04-20_163241.png\" width=\"371\" height=\"328\" alt=\"\u5de6\u8fb9\u76d2\u5b50\" class=\"alignnone size-medium\" \/> <img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201904\/2019-04-20_163310.png\" width=\"377\" height=\"336\" alt=\"\u53f3\u8fb9\u76d2\u5b50\" class=\"alignnone size-medium\" \/><\/p>\n<p><code>.shape-left<\/code>\u5143\u7d20\u5de6\u6d6e\u52a8\u540c\u65f6\u8bbe\u7f6e<code>shape-outside<\/code>\u4e3a\u5012\u4e09\u89d2\uff0c<code>.shape-right<\/code>\u5143\u7d20\u53f3\u6d6e\u52a8\u540c\u65f6\u8bbe\u7f6e<code>shape-outside<\/code>\u4e3a\u6b63\u4e09\u89d2\uff0c\u6b64\u65f6\uff0c<code>&lt;content&gt;<\/code>\u5143\u7d20\u91cc\u9762\u7684\u6587\u5b57\u5185\u5bb9\u5c31\u81ea\u52a8\u5728\u5269\u4f59\u7a7a\u95f4\u73af\u7ed5\u6392\u7248\uff0c\u5f62\u6210\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u6548\u679c\u3002<\/p>\n<p>\u76f8\u5173CSS\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<pre>.shape-left {\r\n    float: left;\r\n    width: 200px; height: 500px;\r\n    <span style=\"color:green;\">\/* \u5012\u4e09\u89d2 *\/<\/span>\r\n    shape-outside: polygon(0 0, 100% 0, 0% 100%);\r\n}\r\n.shape-right {\r\n    float: right;\r\n    width: 200px; height: 500px;\r\n    <span style=\"color:green;\">\/* \u6b63\u4e09\u89d2 *\/<\/span>\r\n    shape-outside: polygon(100% 0, 100% 100%, 0 100%);\r\n}\r\n.content {\r\n    display: block;\r\n}<\/pre>\n<p>\u6548\u679c\u5373\u8fbe\u6210\u3002<\/p>\n<p>\u5b9e\u73b0\u4ee3\u7801\u5f88\u7b80\u5355\uff0c\u5173\u952e\u662f\u601d\u8def\u3002<\/p>\n<h3>\u4e09\u3001\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u4e0e\u5b9e\u6218<\/h3>\n<p>\u4e0d\u89c4\u5219\u5f62\u72b6\u7684\u5e7f\u544a\u66f4\u80fd\u5f15\u8d77\u7528\u6237\u7684\u6ce8\u610f\u529b\uff0c\u4ece\u800c\u63d0\u9ad8\u5e7f\u544a\u70b9\u51fb\u7387\u3002<\/p>\n<p>\u4e8e\u662f\u5bf9\u4e8e\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\uff0c\u5de6\u4e0a\u89d2\u548c\u53f3\u4e0b\u89d2\u7684\u4e09\u89d2\u7a7a\u7f3a\u6b63\u597d\u53ef\u4ee5\u7528\u6765\u653e\u4e24\u4e2a\u4e09\u89d2\u5f62\u5e7f\u544a\uff0c\u65e2\u5145\u5206\u5229\u7528\u7a7a\u95f4\uff0c\u53c8\u6709\u9ad8\u6536\u76ca\u3002<\/p>\n<p>\u524d\u7aef\u5f00\u53d1\u901a\u5e38\u4e0e\u516c\u53f8\u7684\u4e1a\u52a1\u6536\u5165\u76f4\u63a5\u5173\u8054\u4e0d\u5927\uff0c\u4f46\u662f\u8fd9\u91cc\u5374\u4e0d\u4e00\u6837\uff0c\u5982\u679c\u4f60\u5b9e\u73b0\u7684\u65b0\u9896\u7684\u5e03\u5c40\u6548\u679c\u80fd\u591f\u5927\u5e45\u63d0\u9ad8\u516c\u53f8\u7684\u6536\u5165\uff0c\u8bc1\u660e\u4e86\u4f60\u5728\u8fd9\u4e00\u5757\u7684\u4ef7\u503c\uff0c\u76f8\u4fe1\u5bf9\u4f60\u7684\u7ee9\u6548\u4f1a\u5f88\u4e0d\u9519\uff0c\u53ef\u4ee5\u5728\u9879\u76ee\u4e2d\u8bd5\u4e00\u8bd5\u3002<\/p>\n<p>\u7136\u800c\u5b9e\u9645\u5f00\u53d1\u7684\u65f6\u5019\uff0c\u5c55\u793a\u7684\u6587\u5b57\u5185\u5bb9\u6709\u591a\u6709\u5c11\uff0c\u8d70\u5e73\u884c\u56db\u8fb9\u5f62\u5e76\u4e0d\u5408\u9002\uff0c\u56e0\u4e3a\u4f1a\u5bfc\u81f4\u4e09\u89d2\u5f88\u5c0f\uff0c\u6216\u8005\u53f3\u4e0b\u89d2\u7684\u4e09\u89d2\u4f4d\u7f6e\u65e0\u6cd5\u786e\u5b9a\u7684\u95ee\u9898\uff0c\u56e0\u6b64\uff0c\u63a8\u8350\u5b9e\u73b0\u7684\u5e03\u5c40\u5f62\u72b6\u662f\u4e0b\u56fe\u8fd9\u6837\u5b50\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201904\/true-proj-layout.png\" width=\"200\" height=\"332\" alt=\"\u771f\u5b9e\u9879\u76ee\u9760\u8c31\u7684\u5e03\u5c40\u65b9\u5f0f\" class=\"alignnone size-medium\" \/><\/p>\n<h3>\u56db\u3001\u7ed3\u675f\u8bed<\/h3>\n<p>\u4ee5\u540e\u9047\u5230\u4e0d\u89c4\u5219\u5f62\u72b6\u5e03\u5c40\uff0c\u8981\u6709\u6761\u4ef6\u53cd\u5c04\u822c\u7684\u601d\u7ef4\u2014\u2014CSS Shapes\u5e03\u5c40\u3002<\/p>\n<p>CSS Shapes\u5e03\u5c40\u517c\u5bb9\u6027\u5df2\u7ecf\u76f8\u5f53\u4e0d\u9519\u4e86\uff0c\u79fb\u52a8\u7aef\u53ef\u4ee5\u653e\u5fc3\u4f7f\u7528\u3002\u4e3a\u4e86\u907f\u514d\u6c61\u67d3\u6781\u5c11\u90e8\u5206\u8001\u65e7\u624b\u673a\uff0c\u6211\u4eec\u53ef\u4ee5\u8fd9\u4e48\u5904\u7406\uff1a<\/p>\n<pre>@supports (shape-outside: none) {\r\n   <span style=\"color:green;\">\/* CSS Shapes\u76f8\u5173\u4ee3\u7801\u5199\u5728\u8fd9\u91cc *\/<\/span>\r\n}<\/pre>\n<p>\u8fd9\u6837\uff0c\u8001\u65e7\u624b\u673a\u4f9d\u7136\u662f\u5e03\u5c40\u826f\u597d\u7684\u4f20\u7edf\u5757\u72b6\u5e03\u5c40\uff0c\u5927\u591a\u6570\u624b\u673a\u53ef\u4ee5\u4eab\u7528\u65b0\u5f0f\u5e03\u5c40\u5e26\u6765\u7684\u7f8e\u5473\u3002<\/p>\n<p>\u4ee5\u4e0a~\u611f\u8c22\u9605\u8bfb\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/emtion\/emoji\/1f60f.svg\" width=\"20\" height=\"20\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=8592\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=8592<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"\/\/image.zhangxinxu.com\/image\/blog\/201904\/shapes-thumb-deal.png\" width=\"161\" height=\"100\" alt=\"\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u7f29\u7565\u56fe\" class=\"alignright size-medium\" \/><\/p>\n<p>\u672c\u6587\u4e3b\u8981\u4ecb\u7ecd\u5e73\u884c\u56db\u8fb9\u5f62\u5e03\u5c40\u7684\u5b9e\u73b0\u6548\u679c\uff0c\u4f7f\u7528\u4e86\u4e00\u79cd\u53ef\u80fd\u4f60\u6ca1\u7528\u8fc7\uff0c\u4f46\u5b9e\u9645\u9879\u76ee\u4e2d\u53ef\u4ee5\u5b9e\u8df5\u7684\u65b0\u7684CSS\u5e03\u5c40\u65b9\u5f0f\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":[1168,1271,315,1166,1020,231,1421],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/8592"}],"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=8592"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/8592\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=8592"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=8592"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=8592"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}