{"id":5115,"date":"2016-01-09T22:15:47","date_gmt":"2016-01-09T14:15:47","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5115"},"modified":"2018-01-09T00:48:43","modified_gmt":"2018-01-08T16:48:43","slug":"understand-css-stacking-context-order-z-index","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2016\/01\/understand-css-stacking-context-order-z-index\/","title":{"rendered":"\u6df1\u5165\u7406\u89e3CSS\u4e2d\u7684\u5c42\u53e0\u4e0a\u4e0b\u6587\u548c\u5c42\u53e0\u987a\u5e8f"},"content":{"rendered":"<p>by <a href=\"http:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"http:\/\/www.zhangxinxu.com\/\">http:\/\/www.zhangxinxu.com<\/a><br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5115\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=5115<\/a><\/p>\n<h3>\u96f6\u3001\u4e16\u95f4\u7684\u9053\u7406\u90fd\u662f\u60f3\u901a\u7684<\/h3>\n<p>\u5728\u8fd9\u4e2a\u4e16\u754c\u4e0a\uff0c\u51e1\u4e8b\u90fd\u6709\u4e2a\u5148\u540e\u987a\u5e8f\uff0c\u51e1\u7269\u90fd\u6709\u4e2a\u8bba\u8d44\u6392\u8f88\u3002\u6bd4\u65b9\u8bf4\u98df\u5802\u6392\u961f\u6253\u996d\uff0c\u5bf9\u5427\uff0c\u8bb2\u6c42\u5148\u5230\u5148\u5f97\uff0c\u603b\u4e0d\u53ef\u80fd\u4e00\u62e5\u800c\u4e0a\u3002\u518d\u6bd4\u5982\u8bf4\u8bdd\u8bed\u6743\uff0c\u8001\u5a46\u7684\u8bdd\u6c38\u8fdc\u662f\u5bf9\u7684\uff0c\u9886\u5bfc\u7684\u8bdd\u6c38\u8fdc\u662f\u5bf9\u7684\u3002<\/p>\n<p>\u5728CSS\u5c4a\uff0c\u4e5f\u662f\u5982\u6b64\u3002\u53ea\u662f\uff0c\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u5927\u5bb6\u6b4c\u821e\u5347\u5e73\uff0c\u770b\u4e0d\u51fa\u4ec0\u4e48\u5dee\u5f02\uff0c\u5373\u6240\u8c13\u7684\u4f17\u751f\u5e73\u7b49\u3002\u4f46\u662f\uff0c\u5f53\u53d1\u751f\u51b2\u7a81\u53d1\u751f\u7ea0\u845b\u7684\u65f6\u5019\uff0c\u663e\u7136\uff0c\u662f\u4e0d\u53ef\u80fd\u505a\u5230\u5b8c\u5168\u7b49\u540c\u7684\uff0c\u5148\u540e\u987a\u5e8f\uff0c\u8eab\u4efd\u5dee\u5f02\u5c31\u663e\u73b0\u51fa\u6765\u4e86\u3002\u4f8b\u5982\uff0c\u6770\u514b\u548c\u7f57\u65af\uff0c\u53ea\u80fd\u4e00\u4eba\u6d6e\u5728\u6728\u677f\u4e0a\uff0c\u6b64\u65f6\uff0c\u51fa\u73b0\u4e86\u51b2\u7a81\uff0c\u7ed3\u679c\u5927\u5bb6\u90fd\u77e5\u9053\u7684\u3002\u90a3\u5bf9\u4e8eCSS\u4e16\u754c\u4e2d\u7684\u5143\u7d20\u800c\u8a00\uff0c\u6240\u8c13\u7684\u201c\u51b2\u7a81\u201d\u6307\u4ec0\u4e48\u5462\uff0c\u5176\u4e2d\uff0c\u5f88\u91cd\u8981\u7684\u4e00\u4e2a\u5c42\u9762\u5c31\u662f\u201c\u5c42\u53e0\u663e\u793a\u51b2\u7a81\u201d\u3002<\/p>\n<p>\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c\u7f51\u9875\u5185\u5bb9\u662f\u6ca1\u6709\u504f\u79fb\u89d2\u7684\u5782\u76f4\u89c6\u89c9\u5448\u73b0\uff0c\u5f53\u5185\u5bb9\u53d1\u751f\u5c42\u53e0\u7684\u65f6\u5019\uff0c\u4e00\u5b9a\u4f1a\u6709\u4e00\u4e2a\u524d\u540e\u7684\u5c42\u53e0\u987a\u5e8f\u4ea7\u751f\uff0c\u6709\u70b9\u7c7b\u4f3c\u4e8e\u771f\u5b9e\u4e16\u754c\u4e2d\u8bba\u8d44\u6392\u8f88\u7684\u611f\u89c9\u3002<\/p>\n<p>\u800c\u8981\u7406\u89e3\u7f51\u9875\u4e2d\u5143\u7d20\u662f\u5982\u4f55\u201c\u8bba\u8d44\u6392\u8f88\u201d\u7684\uff0c\u5c31\u9700\u8981\u6df1\u5165\u7406\u89e3CSS\u4e2d\u7684\u5c42\u53e0\u4e0a\u4e0b\u6587\u548c\u5c42\u53e0\u987a\u5e8f\u3002<\/p>\n<p>\u6211\u4eec\u5927\u5bb6\u53ef\u80fd\u90fd\u719f\u6089CSS\u4e2d\u7684<code>z-index<\/code>\u5c5e\u6027\uff0c\u9700\u8981\u8ddf\u5927\u5bb6\u8bb2\u7684\u662f\uff0c<code>z-index<\/code>\u5b9e\u9645\u4e0a\u53ea\u662fCSS\u5c42\u53e0\u4e0a\u4e0b\u6587\u548c\u5c42\u53e0\u987a\u5e8f\u4e2d\u7684\u4e00\u53f6\u5c0f\u821f\u3002<\/p>\n<h3>\u4e00\u3001\u4ec0\u4e48\u662f\u5c42\u53e0\u4e0a\u4e0b\u6587<\/h3>\n<p>\u5c42\u53e0\u4e0a\u4e0b\u6587\uff0c\u82f1\u6587\u79f0\u4f5c&#8221;stacking context&#8221;. \u662fHTML\u4e2d\u7684\u4e00\u4e2a\u4e09\u7ef4\u7684\u6982\u5ff5\u3002\u5982\u679c\u4e00\u4e2a\u5143\u7d20\u542b\u6709\u5c42\u53e0\u4e0a\u4e0b\u6587\uff0c\u6211\u4eec\u53ef\u4ee5\u7406\u89e3\u4e3a\u8fd9\u4e2a\u5143\u7d20\u5728z\u8f74\u4e0a\u5c31\u201c\u9ad8\u4eba\u4e00\u7b49\u201d\u3002<\/p>\n<p>\u8fd9\u91cc\u51fa\u73b0\u4e86\u4e00\u4e2a\u540d\u8bcd-<strong>z\u8f74<\/strong>\uff0c\u6307\u7684\u662f\u4ec0\u4e48\u5462\uff1f<\/p>\n<p>\u8868\u793a\u7684\u662f\u7528\u6237\u4e0e\u5c4f\u5e55\u7684\u8fd9\u6761\u770b\u4e0d\u89c1\u7684\u5782\u76f4\u7ebf\uff08\u53c2\u89c1\u4e0b\u56fe\u793a\u610f-\u7ea2\u7ebf\uff09\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/z-aris.png\" width=\"522\" height=\"282\" alt=\"\u7f51\u9875\u4e2dz\u8f74\u793a\u610f\" class=\"alignnone\" \/><\/p>\n<p>\u5c42\u53e0\u4e0a\u4e0b\u6587\u662f\u4e00\u4e2a\u6982\u5ff5\uff0c\u8ddf\u300c<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=4588\">\u5757\u72b6\u683c\u5f0f\u5316\u4e0a\u4e0b\u6587(BFC)<\/a>\u300d\u7c7b\u4f3c\u3002\u7136\u800c\uff0c\u6982\u5ff5\u8fd9\u4e2a\u4e1c\u897f\u662f\u6bd4\u8f83\u865a\u6bd4\u8f83\u62bd\u8c61\u7684\uff0c\u8981\u60f3\u8f7b\u677e\u7406\u89e3\uff0c\u6211\u4eec\u9700\u8981\u5c06\u5176\u5177\u8c61\u5316\u3002<\/p>\n<p>\u600e\u4e48\u4e2a\u5177\u8c61\u5316\u6cd5\u5462\uff1f<\/p>\n<p>\u4f60\u53ef\u4ee5<strong>\u628a\u300c\u5c42\u53e0\u4e0a\u4e0b\u6587\u300d\u7406\u89e3\u4e3a\u5f53\u5b98<\/strong>\uff1a\u7f51\u9875\u4e2d\u6709\u5f88\u591a\u5f88\u591a\u7684\u5143\u7d20\uff0c\u6211\u4eec\u53ef\u4ee5\u770b\u6210\u662f\u771f\u5b9e\u4e16\u754c\u7684\u82b8\u82b8\u4f17\u751f\u3002\u771f\u5b9e\u4e16\u754c\u91cc\uff0c\u6211\u4eec\u5927\u591a\u6570\u4eba\u662f\u666e\u901a\u8001\u767e\u59d3\u4eec\uff0c\u8fd8\u6709\u4e00\u90e8\u5206\u4eba\u662f\u505a\u5b98\u7684\u5b98\u5458\u3002OK\uff0c\u8fd9\u91cc\u7684\u201c\u5b98\u5458\u201d\u5c31\u53ef\u4ee5\u7406\u89e3\u4e3a\u7f51\u9875\u4e2d\u7684\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u3002<\/p>\n<p>\u6362\u53e5\u8bdd\u8bf4\uff0c\u9875\u9762\u4e2d\u7684\u5143\u7d20\u6709\u4e86\u5c42\u53e0\u4e0a\u4e0b\u6587\uff0c\u5c31\u597d\u6bd4\u6211\u4eec\u666e\u901a\u8001\u767e\u59d3\u5f53\u4e86\u5b98\uff0c\u4e00\u65e6\u5f53\u4e86\u5b98\uff0c\u76f8\u6bd4\u666e\u901a\u8001\u767e\u59d3\u800c\u8a00\uff0c\u79bb\u7687\u5e1d\u66f4\u8fd1\u4e86\uff0c\u5bf9\u4e0d\u5bf9\uff0c\u5c31\u7b49\u540c\u4e8e\u7f51\u9875\u4e2d\u5143\u7d20\u7ea7\u522b\u66f4\u9ad8\uff0c\u79bb\u6211\u4eec\u7528\u6237\u66f4\u8fd1\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/emtion\/point.gif\" width=\"150\" height=\"150\" alt=\"\u4f60\u61c2\u7684\" class=\"alignnone\" \/><\/p>\n<h3>\u4e8c\u3001\u4ec0\u4e48\u662f\u5c42\u53e0\u6c34\u5e73<\/h3>\n<p>\u518d\u6765\u8bf4\u8bf4\u5c42\u53e0\u6c34\u5e73\u3002\u201c\u5c42\u53e0\u6c34\u5e73\u201d\u82f1\u6587\u79f0\u4f5c&#8221;stacking level&#8221;\uff0c\u51b3\u5b9a\u4e86\u540c\u4e00\u4e2a\u5c42\u53e0\u4e0a\u4e0b\u6587\u4e2d\u5143\u7d20\u5728z\u8f74\u4e0a\u7684\u663e\u793a\u987a\u5e8f\u3002level\u8fd9\u4e2a\u8bcd\u5f88\u5bb9\u6613\u8ba9\u6211\u4eec\u8054\u60f3\u5230\u6211\u4eec\u771f\u6b63\u4e16\u754c\u4e2d\u7684\u4e09\u516d\u4e5d\u7b49\u3001\u8bba\u8d44\u6392\u8f88\u3002\u771f\u5b9e\u4e16\u754c\u4e2d\uff0c\u6bcf\u4e2a\u4eba\u90fd\u662f\u72ec\u7acb\u7684\u4e2a\u4f53\uff0c\u5305\u62ec\u540c\u5375\u53cc\u80de\u80ce\uff0c\u6709\u5dee\u5f02\u5c31\u6709\u533a\u5206\u3002\u4f8b\u5982\uff0c\u53cc\u80de\u80ce\u867d\u7136\u957f\u5f97\u50cfCtrl+C\/Ctrl+V\u5f97\u5230\u7684\uff0c\u4f46\u5b9e\u9645\u4e0a\uff0c\u51fa\u751f\u65f6\u95f4\u8fd8\u662f\u6709\u5148\u540e\u987a\u5e8f\u7684\uff0c\u5148\u51fa\u751f\u7684\u90a3\u4e2a\u5c31\u5927\uff0c\u5927\u54e5\u6216\u5927\u59d0\u3002\u7f51\u9875\u4e2d\u7684\u5143\u7d20\u4e5f\u662f\u5982\u6b64\uff0c\u9875\u9762\u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u662f\u72ec\u7acb\u7684\u4e2a\u4f53\uff0c\u4ed6\u4eec\u4e00\u5b9a\u662f\u4f1a\u6709\u4e00\u4e2a\u7c7b\u4f3c\u7684\u6392\u540d\u6392\u5e8f\u7684\u60c5\u51b5\u5b58\u5728\u3002\u800c\u8fd9\u4e2a\u6392\u540d\u6392\u5e8f\u3001\u8bba\u8d44\u6392\u8f88\u5c31\u662f\u6211\u4eec\u8fd9\u91cc\u6240\u8bf4\u7684\u201c\u5c42\u53e0\u6c34\u5e73\u201d\u3002\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u7684\u5c42\u53e0\u6c34\u5e73\u53ef\u4ee5\u7406\u89e3\u4e3a\u5b98\u5458\u7684\u804c\u7ea7\uff0c1\u54c12\u54c1\uff0c\u53bf\u957f\u7701\u957f\u4e4b\u7c7b\uff1b\u5bf9\u4e8e\u666e\u901a\u5143\u7d20\uff0c\u8fd9\u4e2a\u561b\u2026\u2026\u4f60\u81ea\u5df1\u968f\u610f\u7406\u89e3\u3002<\/p>\n<p>\u4e8e\u662f\uff0c\u663e\u800c\u6613\u89c1\uff0c\u6240\u6709\u7684\u5143\u7d20\u90fd\u6709\u5c42\u53e0\u6c34\u5e73\uff0c\u5305\u62ec\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\uff0c\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u7684\u5c42\u53e0\u6c34\u5e73\u53ef\u4ee5\u7406\u89e3\u4e3a\u5b98\u5458\u7684\u804c\u7ea7\uff0c1\u54c12\u54c1\uff0c\u53bf\u957f\u7701\u957f\u4e4b\u7c7b\u3002\u7136\u540e\uff0c\u5bf9\u4e8e\u666e\u901a\u5143\u7d20\u7684\u5c42\u53e0\u6c34\u5e73\uff0c\u6211\u4eec\u7684\u63a2\u8ba8\u4ec5\u4ec5\u5c40\u9650\u5728\u5f53\u524d\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u4e2d\u3002\u4e3a\u4ec0\u4e48\u5462\uff1f\u56e0\u4e3a\u5426\u5219\u6ca1\u6709\u610f\u4e49\u3002<\/p>\n<p>\u8fd9\u4e48\u7406\u89e3\u5427~ \u4e0a\u9762\u63d0\u8fc7\u5143\u7d20\u5177\u6709\u5c42\u53e0\u4e0a\u4e0b\u6587\u597d\u6bd4\u5f53\u5b98\uff0c\u5927\u5bb6\u90fd\u77e5\u9053\u7684\uff0c\u8fd9\u5f53\u5b98\u7684\u5bb6\u91cc\u90fd\u6709\u4e2b\u9b1f\u554a\u4fdd\u9556\u554a\u7ba1\u5bb6\u554a\u4ec0\u4e48\u7684\u3002\u6240\u8c13\u6253\u72d7\u770b\u4e3b\u4eba\uff0cA\u5b98\u5458\u5bb6\u91cc\u7684\u7ba1\u5bb6\u548cB\u5b98\u5458\u5bb6\u91cc\u7684\u7ba1\u5bb6\u505aPK\u5b9e\u9645\u4e0a\u662f\u6ca1\u6709\u610f\u4e49\u7684\uff0c\u56e0\u4e3a\u4ed6\u4eec\u725b\u4e0d\u725b\u903c\u5b8c\u5168\u7531\u4ed6\u4eec\u7684\u4e3b\u5b50\u51b3\u5b9a\u7684\u3002\u4e00\u4eba\u5f97\u9053\u9e21\u72ac\u5347\u5929\uff0c\u4f60\u8bf4\u8fd9\u548c\u73c5\u5bb6\u91cc\u7684\u7ba1\u5bb6\u548c\u4e03\u4fa0\u9547\u5a04\u77e5\u53bf\u53bf\u4ee4\u5bb6\u91cc\u7684\u7ba1\u5bb6\u6709\u53ef\u6bd4\u6027\u5417\uff1f\u674e\u603b\u7406\u7684\u79d8\u4e66\u662f\u4e0d\u662f\u5206\u5206\u949f\u706d\u4e86\u4f60\u6751\u652f\u90e8\u4e66\u8bb0\u7684\u79d8\u4e66\uff08\u5982\u679c\u6709\uff09\u3002<\/p>\n<p>\u7ffb\u8bd1\u6210\u672f\u8bed\u5c31\u662f\uff1a\u666e\u901a\u5143\u7d20\u7684\u5c42\u53e0\u6c34\u5e73\u4f18\u5148\u7531\u5c42\u53e0\u4e0a\u4e0b\u6587\u51b3\u5b9a\uff0c\u56e0\u6b64\uff0c\u5c42\u53e0\u6c34\u5e73\u7684\u6bd4\u8f83\u53ea\u6709\u5728\u5f53\u524d\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u4e2d\u624d\u6709\u610f\u4e49\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/emtion\/point.gif\" width=\"150\" height=\"150\" alt=\"\u4f60\u61c2\u7684\" class=\"alignnone\" \/><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u8bf8\u4f4d\u5343\u4e07\u4e0d\u8981\u628a\u5c42\u53e0\u6c34\u5e73\u548cCSS\u7684z-index\u5c5e\u6027\u6df7\u4e3a\u4e00\u8c08\u3002\u6ca1\u9519\uff0c\u67d0\u4e9b\u60c5\u51b5\u4e0bz-index\u786e\u5b9e\u53ef\u4ee5\u5f71\u54cd\u5c42\u53e0\u6c34\u5e73\uff0c\u4f46\u662f\uff0c\u53ea\u9650\u4e8e\u5b9a\u4f4d\u5143\u7d20\u4ee5\u53caflex\u76d2\u5b50\u7684\u5b69\u5b50\u5143\u7d20\uff1b\u800c\u5c42\u53e0\u6c34\u5e73\u6240\u6709\u7684\u5143\u7d20\u90fd\u5b58\u5728\u3002<\/p>\n<h3>\u4e09\u3001\u4ec0\u4e48\u662f\u5c42\u53e0\u987a\u5e8f<\/h3>\n<p>\u518d\u6765\u8bf4\u8bf4\u5c42\u53e0\u987a\u5e8f\u3002\u201c\u5c42\u53e0\u987a\u5e8f\u201d\u82f1\u6587\u79f0\u4f5c&#8221;stacking order&#8221;. \u8868\u793a\u5143\u7d20\u53d1\u751f\u5c42\u53e0\u65f6\u5019\u6709\u7740\u7279\u5b9a\u7684\u5782\u76f4\u663e\u793a\u987a\u5e8f\uff0c\u6ce8\u610f\uff0c\u8fd9\u91cc\u8ddf\u4e0a\u9762\u4e24\u4e2a\u4e0d\u4e00\u6837\uff0c\u4e0a\u9762\u7684<strong>\u5c42\u53e0\u4e0a\u4e0b\u6587\u548c\u5c42\u53e0\u6c34\u5e73\u662f\u6982\u5ff5<\/strong>\uff0c\u800c\u8fd9\u91cc\u7684<strong>\u5c42\u53e0\u987a\u5e8f\u662f\u89c4\u5219<\/strong>\u3002<\/p>\n<p>\u5728CSS2.1\u7684\u5e74\u4ee3\uff0c\u5728CSS3\u8fd8\u6ca1\u6709\u51fa\u73b0\u7684\u65f6\u5019\uff08\u6ce8\u610f\u8fd9\u91cc\u7684\u524d\u63d0\uff09\uff0c\u5c42\u53e0\u987a\u5e8f\u89c4\u5219\u9075\u5faa\u4e0b\u9762\u8fd9\u5f20\u56fe\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/2016-01-07_223349.png\" width=\"605\" height=\"371\" alt=\"\u5c42\u53e0\u987a\u5e8f\" class=\"alignnone\" \/><\/p>\n<p>\u6709\u4eba\u53ef\u80fd\u6709\u89c1\u8fc7\u7c7b\u4f3c\u56fe\uff0c\u90a3\u4e2a\u56fe\u662f\u5f88\u591a\u5f88\u591a\u5e74\u524d\u8001\u5916\u7ed8\u5236\u7684\uff0c\u82f1\u6587\u5185\u5bb9\u3002\u800c\u662f\u66f4\u5173\u952e\u7684\u662f\u56fd\u5185\u4f30\u8ba1\u6ca1\u6709\u540c\u884c\u8fdb\u884c\u8fc7\u9a8c\u8bc1\u4e0e\u5b9e\u8df5\uff0c\u5b9e\u9645\u4e0a\u5f88\u591a\u5173\u952e\u4fe1\u606f\u7f3a\u5931\u3002\u4e0a\u9762\u662f\u6211\u81ea\u5df1\u624b\u52a8\u91cd\u7ed8\u7684\u4e2d\u6587\u7248\u540c\u65f6\u8865\u5145\u5f88\u591a\u5176\u4ed6\u5730\u65b9\u7edd\u5bf9\u6ca1\u6709\u7684\u91cd\u8981\u77e5\u8bc6\u4fe1\u606f\u3002\u5982\u679c\u60f3\u8981\u65e0\u6c34\u5370\u9ad8\u6e05\u5927\u56fe\uff0c\u70b9\u51fb\u8fd9\u91cc\u8d2d\u4e70(0.5\u5143)\u3002<\/p>\n<p>\u7f3a\u5931\u7684\u5173\u952e\u4fe1\u606f\u5305\u62ec\uff1a<\/p>\n<ol>\n<li>\u4f4d\u4e8e\u6700\u4f4e\u6c34\u5e73\u7684<code>border<\/code>\/<code>background<\/code>\u6307\u7684\u662f\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u7684\u8fb9\u6846\u548c\u80cc\u666f\u8272\u3002\u6bcf\u4e00\u4e2a\u5c42\u53e0\u987a\u5e8f\u89c4\u5219\u9002\u7528\u4e8e\u4e00\u4e2a\u5b8c\u6574\u7684\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u3002<\/li>\n<li>\u539f\u56fe\u6ca1\u6709\u5448\u73b0inline-block\u7684\u5c42\u53e0\u987a\u5e8f\uff0c\u5b9e\u9645\u4e0a\uff0cinline-block\u548cinline\u6c34\u5e73\u5143\u7d20\u662f\u540c\u7b49level\u7ea7\u522b\u3002<\/li>\n<li>z-index:0\u5b9e\u9645\u4e0a\u548cz-index:auto\u5355\u7eaf\u4ece\u5c42\u53e0\u6c34\u5e73\u4e0a\u770b\uff0c\u662f\u53ef\u4ee5\u770b\u6210\u662f\u4e00\u6837\u7684\u3002\u6ce8\u610f\u8fd9\u91cc\u7684\u63aa\u8f9e\u2014\u2014\u201c\u5355\u7eaf\u4ece\u5c42\u53e0\u6c34\u5e73\u4e0a\u770b\u201d\uff0c\u5b9e\u9645\u4e0a\uff0c\u4e24\u8005\u5728\u5c42\u53e0\u4e0a\u4e0b\u6587\u9886\u57df\u6709\u7740\u6839\u672c\u6027\u7684\u5dee\u5f02\u3002<\/li>\n<\/ol>\n<p>\u4e0b\u9762\u6211\u8981\u5411\u5927\u5bb6\u53d1\u95ee\u4e86\uff0c\u5927\u5bb6\u6709\u6ca1\u6709\u60f3\u8fc7\uff0c\u4e3a\u4ec0\u4e48\u5185\u8054\u5143\u7d20\u7684\u5c42\u53e0\u987a\u5e8f\u8981\u6bd4\u6d6e\u52a8\u5143\u7d20\u548c\u5757\u72b6\u5143\u7d20\u90fd\u9ad8\uff1f<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/emtion\/ask.gif\" width=\"150\" height=\"150\" alt=\"\u7591\u95ee\" class=\"alignnone\" \/><\/p>\n<p>\u4e3a\u4ec0\u4e48\u5462\uff1f\u6211\u660e\u660e\u611f\u89c9\u6d6e\u52a8\u5143\u7d20\u548c\u5757\u72b6\u5143\u7d20\u8981\u66f4\u5c4c\u4e00\u70b9\u554a\u3002<\/p>\n<p>\u563f\u563f\u563f\uff0c\u6211\u5c31\u4e0d\u5356\u5173\u5b50\u4e86\uff0c\u76f4\u63a5\u770b\u4e0b\u56fe\u7684\u6807\u6ce8\u8bf4\u660e\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/2016-01-07_235108.png\" width=\"599\" height=\"375\" alt=\"\u5c42\u53e0\u987a\u5e8f\u5143\u7d20\u7684\u6807\u6ce8\u8bf4\u660e\" class=\"alignnone\" \/><\/p>\n<p>\u8bf8\u5982<code>border<\/code>\/<code>background<\/code>\u4e00\u822c\u4e3a\u88c5\u9970\u5c5e\u6027\uff0c\u800c\u6d6e\u52a8\u548c\u5757\u72b6\u5143\u7d20\u4e00\u822c\u7528\u4f5c\u5e03\u5c40\uff0c\u800c\u5185\u8054\u5143\u7d20\u90fd\u662f\u5185\u5bb9\u3002\u7f51\u9875\u4e2d\u6700\u91cd\u8981\u7684\u662f\u4ec0\u4e48\uff1f\u5f53\u7136\u662f\u5185\u5bb9\u4e86\u54c8\uff0c\u5bf9\u4e0d\u5bf9\uff01<\/p>\n<p>\u56e0\u6b64\uff0c\u4e00\u5b9a\u8981\u8ba9\u5185\u5bb9\u7684\u5c42\u53e0\u987a\u5e8f\u76f8\u5f53\u9ad8\uff0c\u5f53\u53d1\u751f\u5c42\u53e0\u662f\u5f88\u597d\uff0c\u91cd\u8981\u7684\u6587\u5b57\u554a\u56fe\u7247\u5185\u5bb9\u53ef\u4ee5\u4f18\u5148\u66b4\u9732\u5728\u5c4f\u5e55\u4e0a\u3002\u4f8b\u5982\uff0c\u6587\u5b57\u548c\u6d6e\u52a8\u56fe\u7247\u91cd\u53e0\u7684\u65f6\u5019\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/2016-01-07_235830.jpg\" width=\"500\" height=\"282\" alt=\"\u6d6e\u52a8\u548c\u6587\u5b57\u91cd\u53e0\" class=\"alignnone\" \/><\/p>\n<p>\u4e0a\u9762\u8bf4\u7684\u8fd9\u4e9b\u5c42\u53e0\u987a\u5e8f\u89c4\u5219\u8fd8\u662f\u8001\u65f6\u4ee3\u7684\uff0c\u5982\u679c\u628aCSS3\u4e5f\u7275\u626f\u8fdb\u6765\uff0c\u79d1\u79d1\uff0c\u4e8b\u60c5\u5c31\u4e0d\u4e00\u6837\u4e86\u3002<\/p>\n<h3>\u56db\u3001\u52a1\u5fc5\u7262\u8bb0\u7684\u5c42\u53e0\u51c6\u5219<\/h3>\n<p>\u4e0b\u9762\u8fd9\u4e24\u4e2a\u662f\u5c42\u53e0\u9886\u57df\u7684\u9ec4\u91d1\u51c6\u5219\u3002\u5f53\u5143\u7d20\u53d1\u751f\u5c42\u53e0\u7684\u65f6\u5019\uff0c\u5176\u8986\u76d6\u5173\u7cfb\u9075\u5faa\u4e0b\u97622\u4e2a\u51c6\u5219\uff1a<\/p>\n<ol>\n<li><strong>\u8c01\u5927\u8c01\u4e0a\uff1a<\/strong>\u5f53\u5177\u6709\u660e\u663e\u7684\u5c42\u53e0\u6c34\u5e73\u6807\u793a\u7684\u65f6\u5019\uff0c\u5982\u8bc6\u522b\u7684z-indx\u503c\uff0c\u5728\u540c\u4e00\u4e2a\u5c42\u53e0\u4e0a\u4e0b\u6587\u9886\u57df\uff0c\u5c42\u53e0\u6c34\u5e73\u503c\u5927\u7684\u90a3\u4e00\u4e2a\u8986\u76d6\u5c0f\u7684\u90a3\u4e00\u4e2a\u3002\u901a\u4fd7\u8bb2\u5c31\u662f\u5b98\u5927\u7684\u538b\u6b7b\u5b98\u5c0f\u7684\u3002<\/li>\n<li><strong>\u540e\u6765\u5c45\u4e0a\uff1a<\/strong>\u5f53\u5143\u7d20\u7684\u5c42\u53e0\u6c34\u5e73\u4e00\u81f4\u3001\u5c42\u53e0\u987a\u5e8f\u76f8\u540c\u7684\u65f6\u5019\uff0c\u5728DOM\u6d41\u4e2d\u5904\u4e8e\u540e\u9762\u7684\u5143\u7d20\u4f1a\u8986\u76d6\u524d\u9762\u7684\u5143\u7d20\u3002<\/li>\n<\/ol>\n<p>\u5728CSS\u548cHTML\u9886\u57df\uff0c\u53ea\u8981\u5143\u7d20\u53d1\u751f\u4e86\u91cd\u53e0\uff0c\u90fd\u79bb\u4e0d\u5f00\u4e0a\u9762\u8fd9\u4e24\u4e2a\u9ec4\u91d1\u51c6\u5219\u3002\u56e0\u4e3a\u540e\u9762\u4f1a\u6709\u591a\u4e2a\u5b9e\u4f8b\u8bf4\u660e\uff0c\u8fd9\u91cc\u5c31\u5230\u6b64\u4e3a\u6b62\u3002<\/p>\n<h3>\u4e94\u3001\u5c42\u53e0\u4e0a\u4e0b\u6587\u7684\u7279\u6027<\/h3>\n<p>\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u6709\u5982\u4e0b\u7279\u6027\uff1a<\/p>\n<ul>\n<li>\u5c42\u53e0\u4e0a\u4e0b\u6587\u7684\u5c42\u53e0\u6c34\u5e73\u8981\u6bd4\u666e\u901a\u5143\u7d20\u9ad8\uff08\u539f\u56e0\u540e\u9762\u4f1a\u8bf4\u660e\uff09\uff1b<\/li>\n<li>\u5c42\u53e0\u4e0a\u4e0b\u6587\u53ef\u4ee5\u963b\u65ad\u5143\u7d20\u7684\u6df7\u5408\u6a21\u5f0f\uff08\u89c1<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5155\" title=\"\u7406\u89e3CSS3 isolation: isolate\u7684\u8868\u73b0\u548c\u4f5c\u7528\">\u6b64\u6587\u7b2c\u4e8c\u90e8\u5206\u8bf4\u660e<\/a>\uff09\uff1b<\/li>\n<li><span>\u5c42\u53e0\u4e0a\u4e0b\u6587\u53ef\u4ee5\u5d4c\u5957\uff0c\u5185\u90e8\u5c42\u53e0\u4e0a\u4e0b\u6587\u53ca\u5176\u6240\u6709\u5b50\u5143\u7d20\u5747\u53d7\u5236\u4e8e\u5916\u90e8\u7684\u5c42\u53e0\u4e0a\u4e0b\u6587\u3002<\/span><\/li>\n<li><span>\u6bcf\u4e2a\u5c42\u53e0\u4e0a\u4e0b\u6587\u548c\u5144\u5f1f\u5143\u7d20\u72ec\u7acb\uff0c\u4e5f\u5c31\u662f\u5f53\u8fdb\u884c\u5c42\u53e0\u53d8\u5316\u6216\u6e32\u67d3\u7684\u65f6\u5019\uff0c\u53ea\u9700\u8981\u8003\u8651\u540e\u4ee3\u5143\u7d20\u3002<\/span><\/li>\n<li><span>\u6bcf\u4e2a\u5c42\u53e0\u4e0a\u4e0b\u6587\u662f\u81ea\u6210\u4f53\u7cfb\u7684\uff0c\u5f53\u5143\u7d20\u53d1\u751f\u5c42\u53e0\u7684\u65f6\u5019\uff0c\u6574\u4e2a\u5143\u7d20\u88ab\u8ba4\u4e3a\u662f\u5728\u7236\u5c42\u53e0\u4e0a\u4e0b\u6587\u7684\u5c42\u53e0\u987a\u5e8f\u4e2d\u3002<\/span><\/li>\n<\/ul>\n<p>\u7ffb\u8bd1\u6210\u771f\u5b9e\u4e16\u754c\u8bed\u8a00\u5c31\u662f\uff1a<\/p>\n<ul>\n<li>\u5f53\u5b98\u7684\u6bd4\u8001\u767e\u59d3\u66f4\u6709\u673a\u4f1a\u9762\u89c1\u5723\u4e0a\uff1b<\/li>\n<li>\u9886\u5bfc\u4e0b\u53bb\u8003\u5bdf\uff0c\u4f1a\u88ab\u5f53\u5730\u5b98\u5458\u963b\u9694\u53ea\u770b\u5230\u7e41\u8363\u770b\u4e0d\u5230\u771f\u5b9e\u6c11\u60c5\uff1b<\/li>\n<li>\u4e00\u4e2a\u5bb6\u91cc\uff0c\u7238\u7238\u53ef\u4ee5\u5f53\u5b98\uff0c\u5b69\u5b50\u4e5f\u662f\u53ef\u4ee5\u540c\u65f6\u5f53\u5b98\u7684\u3002\u4f46\u662f\uff0c\u5b69\u5b50\u8fd9\u4e2a\u5b98\u8981\u53d7\u7238\u7238\u63a7\u5236\u3002<\/li>\n<li>\u81ea\u5df1\u5f53\u5b98\uff0c\u5144\u5f1f\u4e0d\u5360\u5149\u3002\u6709\u4ec0\u4e48\u798f\u5229\u6216\u8005\u53d8\u6545\u53ea\u4f1a\u5f71\u54cd\u81ea\u5df1\u7684\u5b69\u5b50\u4eec\u3002<\/li>\n<li>\u6bcf\u4e2a\u5f53\u5b98\u7684\u90fd\u6709\u5c5e\u4e8e\u81ea\u5df1\u7684\u5c0f\u56e2\u4f53\uff0c\u5f53\u5bb6\u7737\u7ba1\u5bb6\u53d1\u751f\u6469\u64e6\u78d5\u78b0\u7684\u65f6\u5019\uff08\u5305\u62ec\u548c\u5176\u4ed6\u5b98\u5458\u7684\u5bb6\u7737\u7ba1\u5bb6\uff09\uff0c\u90fd\u662f\u8981\u4f18\u5148\u770b\u5f53\u5b98\u7684\u4e5f\u5c31\u662f\u4e3b\u5b50\u7684\u8138\u8272\u3002<\/li>\n<\/ul>\n<h3>\u516d\u3001\u5c42\u53e0\u4e0a\u4e0b\u6587\u7684\u521b\u5efa<\/h3>\n<p>\u5356\u4e86\u8fd9\u4e48\u591a\u6587\u5b57\uff0c\u5230\u5e95\u5c42\u53e0\u4e0a\u4e0b\u6587\u662f\u4e2a\u4ec0\u4e48\u9b3c\uff0c\u5012\u662f\u62ff\u51fa\u6765\u7785\u7785\u554a\uff01<\/p>\n<p>\u54c8\u54c8\u3002\u5982\u540c\u5757\u72b6\u683c\u5f0f\u5316\u4e0a\u4e0b\u6587\uff0c\u5c42\u53e0\u4e0a\u4e0b\u6587\u4e5f\u57fa\u672c\u4e0a\u662f\u6709\u4e00\u4e9b\u7279\u5b9a\u7684CSS\u5c5e\u6027\u521b\u5efa\u7684\u3002\u6211\u5c06\u5176\u603b\u7ed3\u4e3a3\u4e2a\u6d41\u6d3e\uff0c\u4e5f\u5c31\u662f\u505a\u5b98\u76843\u79cd\u9014\u5f84\uff1a<\/p>\n<ol>\n<li><strong>\u7687\u4eb2\u56fd\u621a<\/strong>\u6d3e\uff1a\u9875\u9762\u6839\u5143\u7d20\u5929\u751f\u5177\u6709\u5c42\u53e0\u4e0a\u4e0b\u6587\uff0c\u79f0\u4e4b\u4e3a\u201c\u6839\u5c42\u53e0\u4e0a\u4e0b\u6587\u201d\u3002<\/li>\n<li><strong>\u79d1\u8003\u5165\u9009<\/strong>\u6d3e\uff1az-index\u503c\u4e3a\u6570\u503c\u7684\u5b9a\u4f4d\u5143\u7d20\u7684\u4f20\u7edf\u5c42\u53e0\u4e0a\u4e0b\u6587\u3002<\/li>\n<li><strong>\u5176\u4ed6\u5f53\u5b98\u9014\u5f84<\/strong>\uff1a\u5176\u4ed6CSS3\u5c5e\u6027\u3002<\/li>\n<\/ol>\n<p><span class=\"s\">\/\/zxx: \u4e0b\u9762\u5f88\u591a\u4f8b\u5b50\u662f\u5b9e\u65f6CSS\u6548\u679c\uff0c\u5efa\u8bae\u60a8\u53bb<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5115\">\u539f\u5730\u5740\u6d4f\u89c8<\/a>\uff0c\u4ee5\u4fbf\u9884\u89c8\u66f4\u51c6\u786e\u7684\u6548\u679c\u3002<\/span><\/p>\n<p><strong>\u2460. \u6839\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n\u6307\u7684\u662f\u9875\u9762\u6839\u5143\u7d20\uff0c\u4e5f\u5c31\u662f\u6eda\u52a8\u6761\u7684\u9ed8\u8ba4\u7684\u59cb\u4f5c\u4fd1\u8005<code>&lt;html&gt;<\/code>\u5143\u7d20\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\uff0c\u7edd\u5bf9\u5b9a\u4f4d\u5143\u7d20\u5728<code>left<\/code>\/<code>top<\/code>\u7b49\u503c\u5b9a\u4f4d\u7684\u65f6\u5019\uff0c\u5982\u679c\u6ca1\u6709\u5176\u4ed6\u5b9a\u4f4d\u5143\u7d20\u9650\u5236\uff0c\u4f1a\u76f8\u5bf9\u6d4f\u89c8\u5668\u7a97\u53e3\u5b9a\u4f4d\u7684\u539f\u56e0\u3002<\/p>\n<p><strong>\u2461. \u5b9a\u4f4d\u5143\u7d20\u4e0e\u4f20\u7edf\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n\u5bf9\u4e8e\u5305\u542b\u6709<code>position:relative<\/code>\/<code>position:absolute<\/code>\u7684\u5b9a\u4f4d\u5143\u7d20\uff0c\u4ee5\u53caFireFox\/IE\u6d4f\u89c8\u5668\uff08\u4e0d\u5305\u62ecChrome\u7b49webkit\u5185\u6838\u6d4f\u89c8\u5668\uff09\uff08\u76ee\u524d\uff0c\u4e5f\u5c31\u662f2016\u5e74\u521d\u662f\u8fd9\u6837\uff09\u4e0b\u542b\u6709<code>position:fixed<\/code>\u58f0\u660e\u7684\u5b9a\u4f4d\u5143\u7d20\uff0c\u5f53\u5176<code>z-index<\/code>\u503c\u4e0d\u662f<code>auto<\/code>\u7684\u65f6\u5019\uff0c\u4f1a\u521b\u5efa\u5c42\u53e0\u4e0a\u4e0b\u6587\u3002<\/p>\n<p>\u77e5\u9053\u4e86\u8fd9\u4e00\u70b9\uff0c\u6709\u4e9b\u73b0\u8c61\u5c31\u597d\u7406\u89e3\u4e86\u3002<\/p>\n<p>\u5982\u4e0bHTML\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre><span class=\"highlight\">&lt;div style=\"position:relative; <mark>z-index:auto<\/mark>;\">\n    &lt;img src=\"mm1.jpg\" style=\"position:absolute; z-index:2;\">    <span style=\"color:green;\">&lt;-- \u6a2a\u59b9\u5b50 --&gt;<\/span>\n&lt;\/div><\/span>\n<span class=\"highlight\">&lt;div style=\"position:relative; <mark>z-index:auto<\/mark>;\">\n    &lt;img src=\"mm2.jpg\" style=\"position:relative; z-index:1;\">    <span style=\"color:green;\">&lt;-- \u7ad6\u59b9\u5b50 --&gt;<\/span>\n&lt;\/div><\/span><\/pre>\n<\/div>\n<div style=\"position:relative; z-index:auto;\"><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position:absolute; z-index:2;\"><\/div>\n<div style=\"position:relative; z-index:auto;\"><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm2.jpg\" style=\"position:relative; z-index:1;\"><\/div>\n<p>\u5927\u5bb6\u4f1a\u53d1\u73b0\uff0c\u7ad6\u7740\u7684\u59b9\u5b50(mm2)\u88ab\u6a2a\u7740\u7684\u59b9\u5b50(mm1)\u7ed9\u8986\u76d6\u4e86\u3002<\/p>\n<p>\u4e0b\u9762\uff0c\u6211\u4eec\u5bf9\u7236\u7ea7\u7b80\u5355\u8c03\u6574\u4e0b\uff0c\u628a<code>z-index:auto<\/code>\u6539\u6210\u5c42\u53e0\u6c34\u5e73\u4e00\u81f4\u7684<code>z-index:0<\/code>, \u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre><span class=\"highlight\">&lt;div style=\"position:relative; <mark>z-index:0<\/mark>;\">\n    &lt;img src=\"mm1.jpg\" style=\"position:absolute; z-index:2;\">    <span style=\"color:green;\">&lt;-- \u6a2a\u59b9\u5b50 --&gt;<\/span>\n&lt;\/div><\/span>\n<span class=\"highlight\">&lt;div style=\"position:relative; <mark>z-index:0<\/mark>;\">\n    &lt;img src=\"mm2.jpg\" style=\"position:relative; z-index:1;\">    <span style=\"color:green;\">&lt;-- \u7ad6\u59b9\u5b50 --&gt;<\/span>\n&lt;\/div><\/span><\/pre>\n<\/div>\n<div style=\"position:relative; z-index:0;\"><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position:absolute; z-index:2;\"><\/div>\n<div style=\"position:relative; z-index:0;\"><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm2.jpg\" style=\"position:relative; z-index:1;\"><\/div>\n<p>\u5927\u5bb6\u4f1a\u53d1\u73b0\uff0c\u5c3c\u739b\u53cd\u8fc7\u6765\u4e86\uff0c\u7ad6\u7740\u7684\u59b9\u5b50(mm2)\u8fd9\u56de\u8db4\u5728\u4e86\u6a2a\u7740\u7684\u59b9\u5b50(mm1)\u8eab\u4e0a\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/2016-01-08_220622.jpg\" width=\"150\" height=\"134\" alt=\"\u767e\u5408\u5927\u6cd5\u597d\" class=\"alignnone\" \/><\/p>\n<p>\u4e3a\u4ec0\u4e48\u5c0f\u5c0f\u7684\u6539\u53d8\u4f1a\u6709\u60f3\u6cd5\u7684\u7ed3\u679c\u5462\uff1f<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/emtion\/think-2.gif\" width=\"150\" height=\"150\" alt=\"\u601d\u8003\" class=\"alignnone\" \/><\/p>\n<p>\u5dee\u522b\u5c31\u5728\u4e8e\uff0c<code>z-index:0<\/code>\u6240\u5728\u7684<code>&lt;div&gt;<\/code>\u5143\u7d20\u662f\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\uff0c\u800c<code>z-index:auto<\/code>\u6240\u5728\u7684<code>&lt;div&gt;<\/code>\u5143\u7d20\u662f\u4e00\u4e2a\u666e\u901a\u7684\u5143\u7d20\uff0c\u4e8e\u662f\uff0c\u91cc\u9762\u7684\u4e24\u4e2a<code>&lt;img&gt;<\/code>\u59b9\u5b50\u7684\u5c42\u53e0\u6bd4\u8f83\u5c31\u4e0d\u53d7\u7236\u7ea7\u7684\u5f71\u54cd\uff0c\u4e24\u8005\u76f4\u63a5\u5957\u7528\u5c42\u53e0\u9ec4\u91d1\u51c6\u5219\uff0c\u8fd9\u91cc\uff0c\u4e24\u8005\u6709\u7740\u660e\u663e\u4e0d\u4e00\u7684<code>z-index<\/code>\u503c\uff0c\u56e0\u6b64\uff0c\u9075\u5faa\u201c<strong>\u8c01\u5927\u8c01\u4e0a<\/strong>\u201d\u7684\u51c6\u5219\uff0c\u4e8e\u662f\uff0c<code>z-index<\/code>\u4e3a<code>2<\/code>\u7684\u90a3\u4e2a\u6a2a\u59b9\u5b50\uff0c\u5c31\u8db4\u5728\u4e86<code>z-index<\/code>\u4e3a<code>1<\/code>\u7684\u7ad6\u59b9\u5b50\u8eab\u4e0a\u3002<\/p>\n<p>\u800c<code>z-index<\/code>\u4e00\u65e6\u53d8\u6210\u6570\u503c\uff0c\u54ea\u6015\u662f<code>0<\/code>\uff0c\u90fd\u4f1a\u521b\u5efa\u4e00\u4e2a\u5c42\u53e0\u4e0a\u4e0b\u6587\u3002\u6b64\u65f6\uff0c\u5c42\u53e0\u89c4\u5219\u5c31\u53d1\u751f\u4e86\u53d8\u5316\u3002\u5c42\u53e0\u4e0a\u4e0b\u6587\u7684\u7279\u6027\u91cc\u9762\u6700\u540e\u4e00\u6761\u2014\u2014\u81ea\u6210\u4f53\u7cfb\u3002\u4e24\u4e2a<code>&lt;img&gt;<\/code>\u59b9\u5b50\u7684\u5c42\u53e0\u987a\u5e8f\u6bd4\u8f83\u53d8\u6210\u4e86\u4f18\u5148\u6bd4\u8f83\u5176\u7236\u7ea7\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u7684\u5c42\u53e0\u987a\u5e8f\u3002\u8fd9\u91cc\uff0c\u7531\u4e8e\u4e24\u8005\u90fd\u662f<code>z-index:0<\/code>\uff0c\u5c42\u53e0\u987a\u5e8f\u8fd9\u4e00\u5757\u4e24\u8005\u4e00\u6837\u5927\uff0c\u6b64\u65f6\uff0c\u9075\u5faa\u5c42\u53e0\u9ec4\u91d1\u51c6\u5219\u7684\u53e6\u5916\u4e00\u4e2a\u51c6\u5219\u201c<strong>\u540e\u6765\u5c45\u4e0a<\/strong>\u201d\uff0c\u6839\u636e\u5728DOM\u6d41\u4e2d\u7684\u4f4d\u7f6e\u51b3\u5b9a\u8c01\u5728\u4e0a\u9762\uff0c\u4e8e\u662f\uff0c\u4f4d\u4e8e\u540e\u9762\u7684\u7ad6\u7740\u7684\u59b9\u5b50\u5c31\u81ea\u7136\u800c\u7136\u8db4\u5728\u4e86\u6a2a\u7740\u7684\u59b9\u5b50\u8eab\u4e0a\u3002\u5bf9\uff0c\u6ca1\u9519\uff0c<code>&lt;img&gt;<\/code>\u5143\u7d20\u4e0a\u7684<code>z-index<\/code>\u6253\u9171\u6cb9\u4e86\uff01<\/p>\n<p>\u6709\u65f6\u5019\uff0c\u6211\u4eec\u5728\u7f51\u9875\u91cd\u6784\u7684\u65f6\u5019\uff0c\u4f1a\u53d1\u73b0\uff0c<code>z-index<\/code>\u5d4c\u5957\u9519\u4e71\uff0c\u770b\u770b\u662f\u4e0d\u662f\u53d7\u7236\u7ea7\u7684\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u5e72\u6270\u4e86\u3002\u7136\u540e\uff0c\u53ef\u80fd\u6ca1\u591a\u5927\u610f\u4e49\u4e86\uff0c\u4f46\u6211\u8fd8\u662f\u63d0\u4e00\u4e0b\uff0c\u7b97\u662f\u796d\u5960\u4e0b\uff0cIE6\/IE7\u6d4f\u89c8\u5668\u6709\u4e2abug\uff0c\u5c31\u662f<code>z-index:auto<\/code>\u7684\u5b9a\u4f4d\u5143\u7d20\u4e5f\u4f1a\u521b\u5efa\u5c42\u53e0\u4e0a\u4e0b\u6587\u3002\u8fd9\u5c31\u662f\u4e3a\u4ec0\u4e48\u5728\u8fc7\u53bb\uff0cIE6\/IE7\u7684<code>z-index<\/code>\u4f1a\u641e\u6b7b\u4eba\u7684\u539f\u56e0\u3002<\/p>\n<p>\u7136\u540e\uff0c\u6211\u518d\u63d0\u4e00\u4e0b<code>position:fixed<\/code>, \u5728\u8fc7\u53bb\uff0c<code>position:fixed<\/code>\u548c<code>relative\/absolute<\/code>\u5728\u5c42\u53e0\u4e0a\u4e0b\u6587\u8fd9\u4e00\u5757\u662f\u4e00\u8def\u8d27\u8272\uff0c\u90fd\u662f\u9700\u8981<code>z-index<\/code>\u4e3a\u6570\u503c\u624d\u884c\u3002\u4f46\u662f\uff0c\u4e0d\u77e5\u9053\u4ec0\u4e48\u65f6\u5019\u8d77\uff0cChrome\u7b49webkit\u5185\u6838\u6d4f\u89c8\u5668\uff0c<code>position:fixed<\/code>\u5143\u7d20\u5929\u7136\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\uff0c\u65e0\u9700<code>z-index<\/code>\u4e3a\u6570\u503c\u3002\u6839\u636e\u6211\u7684\u6d4b\u8bd5\uff0c\u76ee\u524d\uff0cIE\u4ee5\u53caFireFox\u4ecd\u662f\u8001\u5957\u8def\u3002<\/p>\n<p><strong>\u2462. CSS3\u4e0e\u65b0\u65f6\u4ee3\u7684\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\nCSS3\u7684\u51fa\u73b0\u9664\u4e86\u5e26\u6765\u4e86\u65b0\u5c5e\u6027\uff0c\u540c\u65f6\u8fd8\u5bf9\u8fc7\u53bb\u7684\u5f88\u591a\u89c4\u5219\u53d1\u51fa\u4e86\u6311\u6218\u3002\u4f8b\u5982\uff0cCSS3 <code>transform<\/code><a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2015\/05\/css3-transform-affect\/\">\u5bf9overflow\u9690\u85cf\u5bf9position:fixed\u5b9a\u4f4d\u7684\u5f71\u54cd<\/a>\u7b49\u3002\u800c\u8fd9\u91cc\uff0c\u5c42\u53e0\u4e0a\u4e0b\u6587\u8fd9\u4e00\u5757\u7684\u5f71\u54cd\u8981\u66f4\u52a0\u5e7f\u6cdb\u4e0e\u663e\u8457\u3002<\/p>\n<p>\u5982\u4e0b\uff1a<\/p>\n<ol>\n<li><code>z-index<\/code>\u503c\u4e0d\u4e3a<code>auto<\/code>\u7684<code>flex<\/code>\u9879(\u7236\u5143\u7d20<code>display:flex|inline-flex<\/code>).<\/li>\n<li>\u5143\u7d20\u7684<code>opacity<\/code>\u503c\u4e0d\u662f<code>1<\/code>.<\/li>\n<li>\u5143\u7d20\u7684<code>transform<\/code>\u503c\u4e0d\u662f<code>none<\/code>.<\/li>\n<li>\u5143\u7d20<code>mix-blend-mode<\/code>\u503c\u4e0d\u662f<code>normal<\/code>.<\/li>\n<li>\u5143\u7d20\u7684<code>filter<\/code>\u503c\u4e0d\u662f<code>none<\/code>.<\/li>\n<li>\u5143\u7d20\u7684<code>isolation<\/code>\u503c\u662f<code>isolate<\/code>.<\/li>\n<li><code>will-change<\/code>\u6307\u5b9a\u7684\u5c5e\u6027\u503c\u4e3a\u4e0a\u9762\u4efb\u610f\u4e00\u4e2a\u3002<\/li>\n<li>\u5143\u7d20\u7684<code>-webkit-overflow-scrolling<\/code>\u8bbe\u4e3a<code>touch<\/code>.<\/li>\n<\/ol>\n<p>\u57fa\u672c\u4e0a\u6bcf\u4e00\u9879\u90fd\u6709\u5f88\u591a\u69fd\u70b9\u3002<\/p>\n<p><strong>1. display:flex|inline-flex\u4e0e\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n\u6ce8\u610f\uff0c\u8fd9\u91cc\u7684\u89c4\u5219\u6709\u4e9b<del datetime=\"2016-01-10T17:20:52+00:00\">\u8d1f\u8d23<\/del>\u590d\u6742\u3002\u8981\u6ee1\u8db3\u4e24\u4e2a\u6761\u4ef6\u624d\u80fd\u5f62\u6210\u5c42\u53e0\u4e0a\u4e0b\u6587\uff1a\u6761\u4ef61\u662f\u7236\u7ea7\u9700\u8981\u662f<code>display:flex<\/code>\u6216\u8005<code>display:inline-flex<\/code>\u6c34\u5e73\uff0c\u6761\u4ef62\u662f\u5b50\u5143\u7d20\u7684z-index\u4e0d\u662f<code>auto<\/code>\uff0c\u5fc5\u987b\u662f\u6570\u503c\u3002\u6b64\u65f6\uff0c\u8fd9\u4e2a\u5b50\u5143\u7d20\u4e3a\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\uff0c\u6ca1\u9519\uff0c\u6ce8\u610f\u4e86\uff0c\u662f\u5b50\u5143\u7d20\uff0c\u4e0d\u662fflex\u7236\u7ea7\u5143\u7d20\u3002<\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u7ed9\u5927\u5bb6\u4e0a\u4f8b\u5b50\u5427\u3002<\/p>\n<p>\u5982\u4e0bHTML\u548cCSS\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>&lt;div class=\"box\">\n    &lt;div>\n    \t&lt;img src=\"mm1.jpg\">\n    &lt;\/div>\n&lt;\/div><\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>.box {  }\n.box > div { background-color: blue; z-index: 1; }    <span style=\"color:green;\">\/* \u6b64\u65f6\u8be5div\u662f\u666e\u901a\u5143\u7d20\uff0cz-index\u65e0\u6548 *\/<\/span>\n.box > div > img { \n  position: relative; z-index: -1; right: -150px;     <span style=\"color:green;\">\/* \u6ce8\u610f\u8fd9\u91cc\u662f\u8d1f\u503cz-index *\/<\/span>\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<div>\n<div style=\"z-index:1;background-color:#0074D9; width:256px;\">\n    \t<img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n    <\/div>\n<\/div>\n<p>\u4f1a\u53d1\u73b0\uff0c\u59b9\u5b50\u8dd1\u5230\u84dd\u8272\u80cc\u666f\u7684\u4e0b\u9762\u4e86\u3002\u4e3a\u4ec0\u4e48\u5462\uff1f\u5c42\u53e0\u987a\u5e8f\u56fe\u53ef\u4ee5\u627e\u5230\u7b54\u6848\uff0c\u5982\u4e0b\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/2016-01-08_235511.png\" width=\"332\" height=\"164\" alt=\"\u8d1f\u503cz-index\u7684\u5c42\u53e0\u987a\u5e8f\" class=\"alignnone\" \/><\/p>\n<p>\u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u51fa\u8d1f\u503cz-index\u7684\u5c42\u53e0\u987a\u5e8f\u5728block\u6c34\u5e73\u5143\u7d20\u7684\u4e0b\u9762\uff0c\u800c\u84dd\u8272\u80cc\u666f<code>div<\/code>\u5143\u7d20\u662f\u4e2a\u666e\u901a\u5143\u7d20\uff0c\u56e0\u6b64\uff0c\u59b9\u5b50\u76f4\u63a5\u7a7f\u8d8a\u8fc7\u53bb\uff0c\u5728\u84dd\u8272\u80cc\u666f\u540e\u9762\u7684\u663e\u793a\u4e86\u3002<\/p>\n<p>\u73b0\u5728\uff0c\u6211\u4eecCSS\u5fae\u8c03\u4e0b\uff0c\u589e\u52a0<code>display:flex<\/code>, \u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.box { <mark>display: flex;<\/mark> }\n.box > div { background-color: blue; z-index: 1; }    <span style=\"color:green;\">\/* \u6b64\u65f6\u8be5div\u662f\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\uff0c\u540c\u65f6z-index\u751f\u6548 *\/<\/span>\n.box > div > img { \n  position: relative; z-index: -1; right: -150px;     <span style=\"color:green;\">\/* \u6ce8\u610f\u8fd9\u91cc\u662f\u8d1f\u503cz-index *\/<\/span>\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\uff1a<\/p>\n<div style=\"display: flex;\">\n<div style=\"z-index:1;background-color:#0074D9; width:256px;\" >\n    \t<img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n    <\/div>\n<\/div>\n<p>\u4f1a\u53d1\u73b0\uff0c\u59b9\u5b50\u5728\u84dd\u8272\u80cc\u666f\u4e0a\u9762\u663e\u793a\u4e86\uff0c\u4e3a\u4ec0\u4e48\u5462\uff1f\u5c42\u53e0\u987a\u5e8f\u56fe\u53ef\u4ee5\u627e\u5230\u7b54\u6848\uff0c\u5982\u4e0b\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/2016-01-08_235217.png\" width=\"296\" height=\"132\" class=\"alignnone\" \/><\/p>\n<p>\u4ece\u4e0a\u56fe\u53ef\u4ee5\u770b\u51fa\u8d1f\u503c<code>z-index<\/code>\u7684\u5c42\u53e0\u987a\u5e8f\u5728\u5f53\u524d\u7b2c\u4e00\u4e2a\u7236\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u7684\u4e0a\u9762\uff0c\u800c\u6b64\u65f6\uff0c\u90a3\u4e2a<code>z-index<\/code>\u503c\u4e3a<code>1<\/code>\u7684\u84dd\u8272\u80cc\u666f<code>&lt;div&gt;<\/code>\u7684\u7236\u5143\u7d20\u7684<code>display<\/code>\u503c\u662f<code>flex<\/code>\uff0c\u4e00\u4e0b\u5b50\u5347\u5b98\u53d1\u8d22\u53d8\u6210\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u4e86\uff0c\u4e8e\u662f\uff0c\u56fe\u7247\u5728\u84dd\u8272\u80cc\u666f\u4e0a\u9762\u663e\u793a\u4e86\u3002\u8fd9\u4e2a\u73b0\u8c61\u4e5f\u8bc1\u5b9e\u4e86\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u662f<code>flex<\/code>\u5b50\u5143\u7d20\uff0c\u800c\u4e0d\u662f<code>flex<\/code>\u5bb9\u5668\u5143\u7d20\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u53e6\u5916\uff0c\u8fd9\u4e2a\u4f8b\u5b50\u4e5f\u98a0\u8986\u4e86\u6211\u4eec\u4f20\u7edf\u7684\u5bf9<code>z-index<\/code>\u7684\u7406\u89e3\u3002\u5728CSS2.1\u65f6\u4ee3\uff0c<code>z-index<\/code>\u5c5e\u6027\u5fc5\u987b\u548c\u5b9a\u4f4d\u5143\u7d20\u4e00\u8d77\u4f7f\u7528\u624d\u6709\u4f5c\u7528\uff0c\u4f46\u662f\uff0c\u5728CSS3\u7684\u4e16\u754c\u91cc\uff0c\u975e\u5b9a\u4f4d\u5143\u7d20\u4e5f\u80fd\u548c<code>z-index<\/code>\u6109\u5feb\u5730\u641e\u57fa\u3002<\/p>\n<p><strong>2. opacity\u4e0e\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n\u6211\u4eec\u76f4\u63a5\u770b\u4ee3\u7801\uff0c\u539f\u7406\u548c\u4e0a\u9762\u4f8b\u5b50\u4e00\u6837\uff0c\u5c31\u4e0d\u89e3\u91ca\u4e86\u3002<\/p>\n<p>\u5982\u4e0bHTML\u548cCSS\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>&lt;div class=\"box\">\n    &lt;img src=\"mm1.jpg\">\n&lt;\/div><\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>.box { background-color: blue;  }\n.box > img { \n  position: relative; z-index: -1; right: -150px;\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<div style=\"background-color:#0074D9; width:256px;\">\n  <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n<\/div>\n<p>\u7136\u540e\u4ef7\u683c\u900f\u660e\u5ea6\uff0c\u4f8b\u598250%\u900f\u660e\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.box { background-color: blue; <mark>opacity: 0.5;<\/mark>  }\n.box > img { \n  position: relative; z-index: -1; right: -150px;\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<div style=\"background-color:#0074D9; width:256px; opacity: 0.5;\">\n  <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n<\/div>\n<p>\u539f\u56e0\u5c31\u662f\u534a\u900f\u660e\u5143\u7d20\u5177\u6709\u5c42\u53e0\u4e0a\u4e0b\u6587\uff0c\u59b9\u5b50\u56fe\u7247\u7684<code>z-index:-1<\/code>\u65e0\u6cd5\u7a7f\u900f\uff0c\u4e8e\u662f\uff0c\u5728\u84dd\u8272\u80cc\u666f\u4e0a\u9762\u4e56\u4e56\u663e\u793a\u4e86\u3002<\/p>\n<p><strong>3. transform\u4e0e\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n\u5e94\u7528\u4e86<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2010\/11\/css3-transitions-transforms-animation-introduction\/\">transform\u53d8\u6362<\/a>\u7684\u5143\u7d20\u540c\u6837\u5177\u6709\u83dc\u5355\u4e0a\u4e0b\u6587\u3002<\/p>\n<p>\u6211\u4eec\u76f4\u63a5\u770b\u5e94\u7528\u540e\u7684\u7ed3\u679c\uff0c\u5982\u4e0bCSS\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.box { background-color: blue; <mark>transform: rotate(15deg);<\/mark>  }\n.box > img { \n  position: relative; z-index: -1; right: -150px;\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<div style=\"background-color:#0074D9; width:256px; -ms-transform: rotate(15deg); transform: rotate(15deg);\">\n  <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n<\/div>\n<p>\u59b9\u5b50\u540c\u6837\u5728\u84dd\u8272\u80cc\u666f\u4e4b\u4e0a\u3002<\/p>\n<p><strong>4. mix-blend-mode\u4e0e\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n<code>mix-blend-mode<\/code>\u7c7b\u4f3c\u4e8ePS\u4e2d\u7684\u6df7\u5408\u6a21\u5f0f\uff0c\u4e4b\u524d\u4e13\u95e8\u6709\u6587\u7ae0\u4ecb\u7ecd-\u201c<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2015\/05\/css3-mix-blend-mode-background-blend-mode\/\">CSS3\u6df7\u5408\u6a21\u5f0fmix-blend-mode\u7b80\u4ecb<\/a>\u201d\u3002<\/p>\n<p>\u5143\u7d20\u548c\u767d\u8272\u80cc\u666f\u6df7\u5408\u3002\u65e0\u8bba\u54ea\u79cd\u6a21\u5f0f\uff0c\u8981\u4e48\u5168\u767d\uff0c\u8981\u4e48\u6ca1\u6709\u4efb\u4f55\u53d8\u5316\u3002\u4e3a\u4e86\u8ba9\u5927\u5bb6\u6709\u76f4\u89c2\u611f\u53d7\uff0c\u56e0\u6b64\uff0c\u4e0b\u9762\u4f8b\u5b50\u6211\u7279\u610f\u52a0\u4e86\u4e2a\u539f\u521b\u5e73\u94fa\u80cc\u666f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.box { background-color: blue; <mark>mix-blend-mode: darken;<\/mark>  }\n.box > img { \n  position: relative; z-index: -1; right: -150px;\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<div style=\"background:url(http:\/\/image.zhangxinxu.com\/image\/emtion\/die.gif) repeat-x left center;\">\n<div style=\"background-color:#0074D9; width:256px; mix-blend-mode: darken;\">\n  <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n<\/div>\n<\/div>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u76ee\u524d\uff0cIE\u6d4f\u89c8\u5668(\u5305\u62ecIE14)\u8fd8\u4e0d\u652f\u6301<code>mix-blend-mode<\/code>\uff0c\u56e0\u6b64\uff0c\u8981\u60f3\u770b\u5230\u59b9\u5b50\u5728\u80cc\u666f\u8272\u4e4b\u4e0a\uff0c\u8bf7\u4f7f\u7528Chrome\u6216FireFox\u3002<\/p>\n<p>\u540c\u6837\u7684\uff0c\u56e0\u4e3a\u84dd\u8272\u80cc\u666f\u5143\u7d20\u5347\u7ea7\u6210\u4e86\u5c42\u53e0\u4e0a\u4e0b\u6587\uff0c\u56e0\u6b64\uff0c<code>z-index:-1<\/code>\u65e0\u6cd5\u7a7f\u900f\uff0c\u5728\u84dd\u8272\u80cc\u666f\u4e0a\u663e\u793a\u4e86\u3002<\/p>\n<p><strong>5. filter\u4e0e\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n\u6b64\u5904\u8bf4\u7684<code>filter<\/code>\u662fCSS3\u4e2d\u89c4\u8303\u7684\u6ee4\u955c\uff0c\u4e0d\u662f\u65e7IE\u65f6\u4ee3\u79c1\u6709\u7684\u90a3\u4e9b\uff0c\u867d\u7136\u76ee\u7684\u7c7b\u4f3c\u3002\u540c\u6837\u7684\uff0c\u6211\u4e4b\u524d\u6709\u63d0\u8fc7\uff0c\u4f8b\u5982<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2012\/08\/css-svg-filter-image-grayscale\/\">\u56fe\u7247\u7684\u7070\u5ea6<\/a>\u6216\u8005<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2013\/11\/css-svg-image-blur\/\">\u56fe\u7247\u7684\u6bdb\u73bb\u7483\u6548\u679c<\/a>\u7b49\u3002<\/p>\n<p>\u6211\u4eec\u4f7f\u7528\u5e38\u89c1\u7684\u6a21\u7cca\u6548\u679c\u793a\u610f\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.box { background-color: blue; <mark>filter: blur(5px);<\/mark>  }\n.box > img { \n  position: relative; z-index: -1; right: -150px;\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<div style=\"background-color:#0074D9; width:256px; -webkit-filter: blur(5px); filter: blur(5px);\">\n  <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n<\/div>\n<p>\u597d\u5427\uff0c\u679c\u7136\u88ab\u4f60\u731c\u5bf9\u4e86\uff0c\u59b9\u5b50\u84dd\u8272\u5e8a\u4e0a\u8eba\u7740\uff0c\u53ea\u662f\u4f60\u773c\u955c\u6458\u4e86\uff0c\u770b\u5f97\u6709\u4e9b\u4e0d\u591f\u771f\u5207\u7f62\u4e86\u3002<\/p>\n<p><strong>6. isolation:isolate\u4e0e\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n<code>isolation:isolate<\/code>\u8fd9\u4e2a\u58f0\u660e\u662f<code>mix-blend-mode<\/code>\u5e94\u8fd0\u800c\u751f\u7684\u3002\u9ed8\u8ba4\u60c5\u51b5\u4e0b\uff0c<code>mix-blend-mode<\/code>\u4f1a\u6df7\u5408z\u8f74\u6240\u6709\u5c42\u53e0\u5728\u4e0b\u9762\u7684\u5143\u7d20\uff0c\u8981\u662f\u6211\u4eec\u4e0d\u5e0c\u671b\u67d0\u4e2a\u5c42\u53e0\u7684\u5143\u7d20\u53c2\u4e0e\u6df7\u5408\u600e\u4e48\u529e\u5462\uff1f\u5c31\u662f\u4f7f\u7528<code>isolation:isolate<\/code>\u3002\u7531\u4e8e\u4e00\u8a00\u96be\u5c3d\uff0c\u6211\u7279\u610f\u4e3a\u6b64\u5199\u4e86\u7bc7\u6587\u7ae0\uff1a\u201c<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5155\">\u7406\u89e3CSS3 isolation: isolate\u7684\u8868\u73b0\u548c\u4f5c\u7528<\/a>\u201d\uff0c\u89e3\u91ca\u4e86\u5176\u963b\u9694\u6df7\u5408\u6a21\u5f0f\u7684\u539f\u7406\uff0c\u5efa\u8bae\u5927\u5bb6\u770b\u4e0b\u3002<\/p>\n<p>\u8981\u6f14\u793a\u8fd9\u4e2a\u6548\u679c\uff0c\u6211\u9700\u8981\u91cd\u65b0\u8bbe\u8ba1\u4e0b\uff0c\u5982\u4e0bHTML\u7ed3\u6784\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>&lt;img src=\"img\/mm2.jpg\" class=\"mode\">\n&lt;div class=\"box\">\n    &lt;img src=\"mm1.jpg\">\n&lt;\/div><\/pre>\n<\/div>\n<p>CSS\u4e3b\u8981\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.mode {\n  <span style=\"color:green;\">\/* \u7ad6\u59b9\u5b50\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u540c\u65f6\u6df7\u5408\u6a21\u5f0f *\/<\/span>\n  position: absolute; mix-blend-mode: darken;\n}    \n.box {\n  background: blue;         \n}\n.box > img { \n  position: relative; z-index: -1;\n}<\/pre>\n<\/div>\n<p>\u7ed3\u6784\u5982\u4e0b\uff1a<\/p>\n<div><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm2.jpg\" style=\"position: absolute;mix-blend-mode: darken; \"><\/div>\n<div style=\"background-color:#0074D9; width:256px;height:250px;\">\n  <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n<\/div>\n<p>\u4f1a\u53d1\u73b0\uff0c\u6a2a\u59b9\u5b50\u88ab\u6df7\u5408\u6a21\u5f0f\u4e86\u3002\u6b64\u65f6\uff0c\u6211\u4eec\u7ed9\u59b9\u5b50\u6240\u5728\u5bb9\u5668\u589e\u52a0<code>isolation:isolate<\/code>\uff0c\u5982\u4e0bCSS\u6240\u793a\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.mode {\n  <span style=\"color:green;\">\/* \u7ad6\u59b9\u5b50\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u540c\u65f6\u6df7\u5408\u6a21\u5f0f *\/<\/span>\n  position: absolute; mix-blend-mode: darken;\n}    \n.box {\n  background: blue; <mark>isolation:isolate;<\/mark>         \n}\n.box > img { \n  position: relative; z-index: -1;\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u4e3a\uff1a<\/p>\n<div><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm2.jpg\" style=\"position: absolute;mix-blend-mode: darken;\"><\/div>\n<div style=\"background-color:#0074D9; width:256px;height:250px;isolation:isolate;\">\n  <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n<\/div>\n<p>\u4f1a\u53d1\u73b0\u6a2a\u7740\u7684\u59b9\u5b50\u8dd1\u5230\u84dd\u8272\u80cc\u666f\u4e0a\u9762\u4e86\u3002\u8fd9\u8868\u660e\u786e\u5b9e\u521b\u5efa\u4e86\u5c42\u53e0\u4e0a\u4e0b\u6587\u3002<\/p>\n<p><strong>7. will-change\u4e0e\u5c42\u53e0\u4e0a\u4e0b\u6587<\/strong><br \/>\n\u5173\u4e8e<code>will-change<\/code>\uff0c\u5982\u679c\u6709\u540c\u5b66\u8fd8\u4e0d\u4e86\u89e3\uff0c\u53ef\u4ee5\u53c2\u89c1\u6211\u4e4b\u524d\u5199\u7684\u6587\u7ae0\uff1a\u201c<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/2015\/11\/css3-will-change-improve-paint\/\">\u4f7f\u7528CSS3 will-change\u63d0\u9ad8\u9875\u9762\u6eda\u52a8\u3001\u52a8\u753b\u7b49\u6e32\u67d3\u6027\u80fd<\/a>\u201d\u3002<\/p>\n<p>\u90fd\u662f\u7c7b\u4f3c\u7684\u6f14\u793a\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>.box { background-color: blue; <mark>will-change: transform;<\/mark>  }\n.box > img { \n  position: relative; z-index: -1; right: -150px;\n}<\/pre>\n<\/div>\n<p>\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n<div style=\"background-color:#0074D9; width:256px; will-change: transform;\">\n  <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative; z-index: -1; right: -150px;\">\n<\/div>\n<p>\u679c\u7136\u4e0d\u51fa\u6240\u6599\uff0c\u59b9\u5b50\u4e0a\u4e86\u84dd\u8272\u7684\u80cc\u666f\u3002<\/p>\n<h3>\u4e03\u3001\u5c42\u53e0\u4e0a\u4e0b\u6587\u4e0e\u5c42\u53e0\u987a\u5e8f<\/h3>\n<p>\u672c\u6587\u591a\u6b21\u63d0\u5230\uff0c\u4e00\u65e6\u666e\u901a\u5143\u7d20\u5177\u6709\u4e86\u5c42\u53e0\u4e0a\u4e0b\u6587\uff0c\u5176\u5c42\u53e0\u987a\u5e8f\u5c31\u4f1a\u53d8\u9ad8\u3002\u90a3\u5b83\u7684\u5c42\u53e0\u987a\u5e8f\u7a76\u7adf\u5728\u54ea\u4e2a\u4f4d\u7f6e\u5462\uff1f<\/p>\n<p>\u8fd9\u91cc\u9700\u8981\u5206\u4e24\u79cd\u60c5\u51b5\u8ba8\u8bba\uff1a<\/p>\n<ol>\n<li>\u5982\u679c\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u4e0d\u4f9d\u8d56<code>z-index<\/code>\u6570\u503c\uff0c\u5219\u5176\u5c42\u53e0\u987a\u5e8f\u662f<code>z-index:auto<\/code>\u53ef\u770b\u6210<code>z:index:0<\/code>\u7ea7\u522b\uff1b<\/li>\n<li>\u5982\u679c\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u4f9d\u8d56<code>z-index<\/code>\u6570\u503c\uff0c\u5219\u5176\u5c42\u53e0\u987a\u5e8f\u7531<code>z-index<\/code>\u503c\u51b3\u5b9a\u3002<\/li>\n<\/ol>\n<p>\u4e8e\u662f\u4e4e\uff0c\u6211\u4eec\u4e0a\u9762\u63d0\u4f9b\u7684\u5c42\u53e0\u987a\u5e8f\u8868\uff0c\u5b9e\u9645\u4e0a\u8fd8\u662f\u7f3a\u5c11\u5176\u4ed6\u91cd\u8981\u4fe1\u606f\u3002\u6211\u53c8\u82b1\u529f\u592b\u91cd\u65b0\u7ed8\u5236\u4e86\u4e00\u4e2a\u66f4\u5b8c\u6574\u76847\u9636\u5c42\u53e0\u987a\u5e8f\u56fe\uff08\u540c\u6837\u7684\u7248\u6743\u6240\u6709\uff0c\u5546\u4e1a\u8bf7\u8d2d\u4e70\uff0c\u53ef\u5f97\u65e0\u6c34\u5370\u5927\u56fe\uff09\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/2016-01-09_211116.png\" width=\"581\" height=\"379\" alt=\"\u66f4\u5b8c\u6574\u76847\u9636\u5c42\u53e0\u987a\u5e8f\u56fe\" class=\"alignnone\" \/><\/p>\n<p>\u5927\u5bb6\u77e5\u9053\u4e3a\u4ec0\u4e48\u5b9a\u4f4d\u5143\u7d20\u4f1a\u5c42\u53e0\u5728\u666e\u901a\u5143\u7d20\u7684\u4e0a\u9762\u5417\uff1f<\/p>\n<p>\u5176\u6839\u672c\u539f\u56e0\u5c31\u5728\u4e8e\uff0c\u5143\u7d20\u4e00\u65e6\u6210\u4e3a\u5b9a\u4f4d\u5143\u7d20\uff0c\u5176<code>z-index<\/code>\u5c31\u4f1a\u81ea\u52a8\u751f\u6548\uff0c\u6b64\u65f6\u5176<code>z-index<\/code>\u5c31\u662f\u9ed8\u8ba4\u7684<code>auto<\/code>\uff0c\u4e5f\u5c31\u662f<code>0<\/code>\u7ea7\u522b\uff0c\u6839\u636e\u4e0a\u9762\u7684\u5c42\u53e0\u987a\u5e8f\u8868\uff0c\u5c31\u4f1a\u8986\u76d6<code>inline<\/code>\u6216<code>block<\/code>\u6216<code>float<\/code>\u5143\u7d20\u3002<\/p>\n<p>\u800c\u4e0d\u652f\u6301z-index\u7684\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u5929\u7136<code>z-index:auto<\/code>\u7ea7\u522b\uff0c\u4e5f\u5c31\u610f\u5473\u7740\uff0c\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u548c\u5b9a\u4f4d\u5143\u7d20\u662f\u4e00\u4e2a\u5c42\u53e0\u987a\u5e8f\u7684\uff0c\u4e8e\u662f\u5f53\u4ed6\u4eec\u53d1\u751f\u5c42\u53e0\u7684\u65f6\u5019\uff0c\u9075\u5faa\u7684\u662f\u201c\u540e\u6765\u5c45\u4e0a\u201d\u51c6\u5219\u3002<\/p>\n<p>\u6211\u4eec\u53ef\u4ee5\u901f\u5ea6\u6d4b\u8bd5\u4e0b\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>&lt;img src=\"mm1\" style=\"position:relative\">\n&lt;img src=\"mm2\" style=\"transform:scale(1);\"><\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>&lt;img src=\"mm2\" style=\"transform:scale(1);\">\n&lt;img src=\"mm1\" style=\"position:relative\"><\/pre>\n<\/div>\n<p><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative;\"><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm2.jpg\" style=\"-ms-transform:scale(1);transform:scale(1);margin-left:-100px;\"><br \/>\n<img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm2.jpg\" style=\"-ms-transform:scale(1);transform:scale(1);\"><img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"position: relative;margin-left:-100px;\"><\/p>\n<p>\u4f1a\u53d1\u73b0\uff0c\u4e24\u8005\u6837\u5f0f\u4e00\u6a21\u4e00\u6837\uff0c\u4ec5\u4ec5\u662f\u5728DOM\u6d41\u4e2d\u7684\u4f4d\u7f6e\u4e0d\u4e00\u6837\uff0c\u5bfc\u81f4\u4ed6\u4eec\u7684\u5c42\u53e0\u8868\u73b0\u4e0d\u4e00\u6837\uff0c\u540e\u9762\u7684\u59b9\u5b50\u8db4\u5728\u4e86\u524d\u9762\u59b9\u5b50\u7684\u8eab\u4e0a\u3002\u8fd9\u4e5f\u8bf4\u660e\u4e86\uff0c\u5c42\u53e0\u4e0a\u4e0b\u6587\u5143\u7d20\u7684\u5c42\u53e0\u987a\u5e8f\u5c31\u662f<code>z-index:auto<\/code>\u7ea7\u522b\u3002<\/p>\n<p><strong>z-index\u503c\u4e0e\u5c42\u53e0\u987a\u5e8f<\/strong><br \/>\n\u5982\u679c\u5143\u7d20\u652f\u6301z-index\u503c\uff0c\u5219\u5c42\u53e0\u987a\u5e8f\u5c31\u8981\u597d\u7406\u89e3\u4e9b\u4e86\uff0c\u6bd4\u8f83\u6570\u503c\u5927\u5c0f\u561b\uff0c\u5c0f\u76c6\u53cb\u90fd\u4f1a\uff0c\u672c\u8d28\u4e0a\u662f\u5e94\u7528\u7684\u201c\u8c01\u5927\u8c01\u4e0a\u201d\u7684\u51c6\u5219\u3002\u5728\u4ee5\u524d\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5173\u5fc3\u5b9a\u4f4d\u5143\u7d20\u7684z-index\u5c31\u597d\uff0c\u4f46\u662f\uff0c\u5728CSS3\u65f6\u4ee3\uff0cflex\u5b50\u9879\u4e5f\u652f\u6301<code>z-index<\/code>\uff0c\u4f7f\u5f97\u6211\u4eec\u9762\u5bf9\u7684\u60c5\u51b5\u6bd4\u4ee5\u524d\u8981\u8d1f\u590d\u6742\u3002\u7136\u800c\uff0c\u597d\u7684\u662f\uff0c\u89c4\u5219\u90fd\u662f\u4e00\u6837\u7684\uff0c\u5bf9\u4e8e<code>z-index<\/code>\u7684\u4f7f\u7528\u548c\u8868\u73b0\u4e5f\u662f\u5982\u6b64\uff0c\u5957\u7528\u4e0a\u9762\u76847\u9636\u5c42\u53e0\u987a\u5e8f\u8868\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u540c\u6837\uff0c\u4e3e\u4e2a\u7b80\u5355\u4f8b\u5b50\uff0c\u770b\u4e0b<code>z-index:-1<\/code>\u548c<code>z-index:1<\/code>\u53d8\u5316\u5bf9\u5c42\u53e0\u8868\u73b0\u7684\u5f71\u54cd\uff0c\u5982\u4e0b\u4e24\u6bb5HTML\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>&lt;div style=\"display:flex; background:blue;\">\n   &lt;img src=\"mm1.jpg\" style=\"<mark>z-index:-1;<\/mark>\">\n&lt;\/div><\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>&lt;div style=\"display:flex; background:blue;\">\n   &lt;img src=\"mm1.jpg\" style=\"<mark>z-index:1;<\/mark>\">\n&lt;\/div><\/pre>\n<\/div>\n<p>\u6700\u540e\uff0c\u4f1a\u53d1\u73b0\uff0c<code>z-index:-1<\/code>\u8dd1\u5230\u4e86\u80cc\u666f\u8272\u5c0f\u9762\uff0c\u800c<code>z-index:1<\/code>\u9ad8\u9ad8\u5728\u4e0a\u3002<\/p>\n<div style=\"display: flex;background-color:#0074D9; width:256px;\">\n   <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"z-index:-1; margin-left: 150px;\">\n<\/div>\n<div class=\"mt10\" style=\"display: flex;background-color:#0074D9; width:256px;\">\n   <img decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/study\/s\/s256\/mm1.jpg\" style=\"z-index:1; margin-left: 150px;\">\n<\/div>\n<p><strong>\u4e00\u4e2a\u4e0e\u5c42\u53e0\u4e0a\u4e0b\u6587\u76f8\u5173\u7684\u6709\u8da3\u7684\u663e\u793a\u73b0\u8c61<\/strong><br \/>\n\u5728\u5b9e\u9645\u9879\u76ee\u4e2d\uff0c\u6211\u4eec\u53ef\u80fd\u4f1a\u6e10\u8fdb\u4f7f\u7528CSS3\u7684fadeIn\u6de1\u5165animation\u6548\u679c\u589e\u5f3a\u4f53\u9a8c\uff0c\u4e8e\u662f\uff0c\u6211\u4eec\u53ef\u80fd\u5c31\u4f1a\u9047\u5230\u7c7b\u4f3c\u4e0b\u9762\u7684\u73b0\u8c61\uff1a<\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a class=\"a_link\" href=\"http:\/\/www.zhangxinxu.com\/study\/201601\/css3-fadein-animation-stacking-context.html\" target=\"_blank\">CSS3 fadeIn\u6de1\u5165animation\u52a8\u753b\u6709\u8da3\u73b0\u8c61<\/a><\/p>\n<p>\u6709\u4e00\u4e2a\u7edd\u5bf9\u5b9a\u4f4d\u7684\u9ed1\u8272\u534a\u900f\u660e\u5c42\u8986\u76d6\u5728\u56fe\u7247\u4e0a\uff0c\u9ed8\u8ba4\u663e\u793a\u662f\u8fd9\u6837\u7684\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201801\/2018-01-09_004641.png\" width=\"358\" height=\"294\" alt=\"\u6587\u5b57\u5728\u59b9\u5b50\u4e0a\" class=\"alignnone\" \/><\/p>\n<p>\u4f46\u662f\uff0c\u4e00\u65e6\u56fe\u7247\u5f00\u59cb\u8d70fadeIn\u6de1\u51fa\u7684CSS3\u52a8\u753b\uff0c\u6587\u5b57\u8dd1\u5230\u56fe\u7247\u540e\u9762\u53bb\u4e86<img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/36.gif\" align=\"absmiddle\">\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201801\/2018-01-09_004654.png\" width=\"346\" height=\"274\" alt=\"\u6587\u5b57\u8dd1\u5230\u56fe\u7247\u540e\u9762\" class=\"alignnone\" \/><\/p>\n<p>\u4e3a\u4ec0\u4e48\u4f1a\u8fd9\u6837\uff1f<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u5b66\u4e86\u672c\u6587\u7684\u5185\u5bb9\uff0c\u5c31\u5f88\u7b80\u5355\u4e86\uff01fadeIn\u52a8\u753b\u672c\u8d28\u662f<code>opacity<\/code>\u900f\u660e\u5ea6\u7684\u53d8\u5316\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>@keyframes fadeIn {\n  0% { \n    opacity: 0;\n  }\n  100% {\n    opacity: 1;\n  }\n}<\/pre>\n<\/div>\n<p>\u8981\u77e5\u9053\uff0c<code>opacity<\/code>\u7684\u503c\u4e0d\u662f<code>1<\/code>\u7684\u65f6\u5019\uff0c\u662f\u5177\u6709\u5c42\u53e0\u4e0a\u4e0b\u6587\u7684\uff0c\u5c42\u53e0\u987a\u5e8f\u662f<code>z-index:auto<\/code>\u7ea7\u522b\uff0c\u8ddf\u6ca1\u6709<code>z-index<\/code>\u503c\u7684<code>absolute<\/code>\u7edd\u5bf9\u5b9a\u4f4d\u5143\u7d20\u662f\u5e73\u8d77\u5e73\u5750\u7684\u3002\u800c\u672cdemo\u4e2d\u7684\u6587\u5b57\u5143\u7d20\u5728\u56fe\u7247\u5143\u7d20\u7684\u524d\u9762\uff0c\u4e8e\u662f\uff0c\u5f53CSS3\u52a8\u753b\u53ea\u8981\u4e0d\u662f\u6700\u7ec8\u4e00\u77ac\u95f4\u7684<code>opacity: 1<\/code>\uff0c\u4f4d\u4e8eDOM\u6d41\u540e\u9762\u7684\u56fe\u7247\u5c31\u4f1a\u9075\u5faa\u201c\u540e\u6765\u5c45\u4e0a\u201d\u51c6\u5219\uff0c\u8986\u76d6\u6587\u5b57\u3002<\/p>\n<p>\u8fd9\u5c31\u662f\u539f\u56e0\uff0c\u4e8e\u662f\uff0c\u6211\u4eec\u60f3\u8981\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u5c31\u5f88\u7b80\u5355\u3002<\/p>\n<p>1. \u8c03\u6574DOM\u6d41\u7684\u5148\u540e\u987a\u5e8f\uff1b<br \/>\n2. \u63d0\u9ad8\u6587\u5b57\u7684\u5c42\u53e0\u987a\u5e8f\uff0c\u4f8b\u5982\uff0c\u8bbe\u7f6e<code>z-index:1<\/code>;<\/p>\n<h3>\u516b\u3001\u7ed3\u675f\u8bed<\/h3>\n<p>\u53ea\u8981\u5143\u7d20\u53d1\u751f\u5c42\u53e0\uff0c\u8981\u89e3\u91ca\u5176\u8868\u73b0\uff0c\u57fa\u672c\u4e0a\u5c31\u672c\u6587\u7684\u8fd9\u4e9b\u5185\u5bb9\u4e86\u3002<\/p>\n<p>\u6211\u53d1\u73b0\u5f88\u591a\u91cd\u6784\u5c0f\u4f19\u4f34\u90fd\u6709z-index\u6ee5\u7528\uff0c\u6216\u8005\u4f7f\u7528\u4e0d\u89c4\u8303\u7684\u95ee\u9898\u3002\u6211\u89c9\u5f97\u6700\u4e3b\u8981\u7684\u539f\u56e0\u8fd8\u662f\u5bf9\u7406\u89e3\u5c42\u53e0\u4e0a\u4e0b\u6587\u4ee5\u53ca\u5c42\u53e0\u987a\u5e8f\u8fd9\u4e9b\u6982\u5ff5\u90fd\u4e0d\u4e86\u89e3\u3002\u4f8b\u5982\uff0c\u53ea\u8981\u4f7f\u7528\u4e86\u5b9a\u4f4d\u5143\u7d20\uff0c\u5c24\u5176<code>absolute<\/code>\u7edd\u5bf9\u5b9a\u4f4d\uff0c\u90fd\u79bb\u4e0d\u5f00\u8bbe\u7f6e\u4e00\u4e2a<code>z-index<\/code>\u503c\uff1b\u6216\u8005\u53ea\u8981\u5143\u7d20\u88ab\u5176\u4ed6\u5143\u7d20\u8986\u76d6\u4e86\uff0c\u4f8b\u5982\u53d8\u6210\u5b9a\u4f4d\u5143\u7d20\u6216\u8005\u589e\u52a0<code>z-index<\/code>\u503c\u5347\u7ea7\u3002\u9875\u9762\u4e00\u590d\u6742\uff0c\u5fc5\u7136\u641e\u5f97\u4e71\u4e03\u516b\u7cdf\u3002<\/p>\n<p>\u5b9e\u9645\u4e0a\uff0c\u5728\u6211\u770b\u6765\uff0c\u89c9\u5f97\u591a\u6570\u5e38\u89c1\uff0cz-index\u6839\u672c\u5c31\u6ca1\u6709\u51fa\u73b0\u7684\u5fc5\u8981\u3002\u77e5\u9053\u4e86\u5185\u8054\u5143\u7d20\u7684\u5c42\u53e0\u6c34\u5e73\u6bd4\u5757\u72b6\u5143\u7d20\u9ad8\uff0c\u4e8e\u662f\uff0c\u67d0\u6761\u7ebf\u4f60\u60f3\u8986\u76d6\u4e0a\u53bb\u7684\u65f6\u5019\uff0c\u9700\u8981\u8bbe\u7f6e<code>position:relative<\/code>\u5417\uff1f\u4e0d\u9700\u8981\uff0c<code>inline-block<\/code>\u5316\u5c31\u53ef\u4ee5\u3002\u56e0\u4e3aIE6\/IE7 <code>position:relative<\/code>\u4f1a\u521b\u5efa\u5c42\u53e0\u4e0a\u4e0b\u6587\uff0c\u5f88\u70e6\u7684\u3002<\/p>\n<p>OK\uff0c\u672c\u6587\u5df2\u7ecf\u591f\u957f\u4e86\uff0c\u5c31\u4e0d\u591a\u5570\u55e6\u4e86\u3002<\/p>\n<p>\u884c\u4e3a\u5306\u5fd9\uff0c\u51fa\u9519\u5728\u6240\u96be\u514d\uff0c\u6b22\u8fce\u5927\u529b\u6307\u6b63\u3002\u4e5f\u6b22\u8fce\u5404\u79cd\u5f62\u5f0f\u7684\u4ea4\u6d41\uff0c\u6216\u8005\u6307\u51fa\u6587\u4e2d\u6982\u5ff5\u6027\u7684\u9519\u8bef\u3002<\/p>\n<p>\u611f\u8c22\u9605\u8bfb\uff01<\/p>\n<p> <img decoding=\"async\" src=\"http:\/\/mat1.gtimg.com\/www\/mb\/images\/face\/14.gif\" align=\"absmiddle\"><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\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\u5185\u7f6e\u6837\u5f0f\u548c\u5176\u4ed6\u91cd\u8981\u77e5\u8bc6\u94fe\u63a5\uff0c\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5115\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=5115<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><a href=\"http:\/\/www.zhangxinxu.com\/wordpress\/?p=5115\" title=\"\u70b9\u51fb\u67e5\u770b\u672c\u6587\"><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201601\/stacking-context-cover.jpg\" width=\"550\" height=\"170\" class=\"imgpad mb10\" alt=\"\"><\/a><\/p>\n<p>\u672c\u6587\u662f\u6700\u8fd11-2\u4e2a\u6708\u6700\u7528\u5fc3\u7684\u6587\u7ae0\uff0c\u7406\u89e3\u672c\u6587\u5185\u5bb9\uff0c\u5c31\u4f1a\u660e\u767d\u7f51\u9875\u4e2d\u5143\u7d20\u5c42\u53e0\u7684\u65f6\u5019\u4e3a\u4ec0\u4e48\u4f1a\u8fd9\u6837\u8868\u73b0\u4e86\uff0c\u76f8\u4fe1\u672c\u6587\u7684\u5185\u5bb9\u4e00\u5b9a\u4f1a\u5bf9\u60a8\u7684\u5b66\u4e60\u6709\u6240\u5e2e\u52a9\u7684\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":[276,368,524,994,398,275,287,1038,272,1035,1037,1036],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/5115"}],"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=5115"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/5115\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=5115"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=5115"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=5115"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}