{"id":2224,"date":"2012-06-27T17:51:33","date_gmt":"2012-06-27T09:51:33","guid":{"rendered":"http:\/\/vanabel.sinaapp.com\/?p=2224"},"modified":"2012-06-27T17:51:33","modified_gmt":"2012-06-27T09:51:33","slug":"%e8%bd%ac%e8%bd%bd%e7%ba%afcss%e6%97%a0hacks%e7%9a%84%e8%b7%a8%e6%b8%b8%e8%a7%88%e5%99%a8%e8%87%aa%e9%80%82%e5%ba%94%e9%ab%98%e5%ba%a6%e5%a4%9a%e5%88%97%e5%b8%83%e5%b1%80","status":"publish","type":"post","link":"https:\/\/lttt.vanabel.cn\/?p=2224","title":{"rendered":"[\u8f6c\u8f7d]\u7eafCSS\u65e0hacks\u7684\u8de8\u6e38\u89c8\u5668\u81ea\u9002\u5e94\u9ad8\u5ea6\u591a\u5217\u5e03\u5c40"},"content":{"rendered":"<p>\u8bf4\u660e: \u539f\u6587\u7ffb\u8bd1\u81ea<a href=\"http:\/\/matthewjamestaylor.com\/about\" target=\"_blank\">Matthew James Taylor<\/a>\u7684<a href=\"http:\/\/matthewjamestaylor.com\/blog\/equal-height-columns-cross-browser-css-no-hacks\" target=\"_blank\">Equal Height Columns with Cross-Browser CSS and No Hacks<\/a>\uff0c\u6709\u4e9b\u90e8\u5206\u6839\u636e\u6211\u7684\u7406\u89e3\u6539\u4e86\uff0c\u8ba9\u4e00\u4e9b\u521d\u5fc3\u8005\u66f4\u597d\u7406\u89e3\u3002<br \/>\n<a href=\"http:\/\/www.jb51.net\/css\/22506.html\" target=\"_blank\">\u7ffb\u8bd1\u540e\u7684\u539f\u6587\u94fe\u63a5<\/a><\/p>\n<p>\u5229\u7528\u7eafCSS\u521b\u5efa\u4e00\u4e2a\u7b49\u9ad8\u591a\u5217\u7684\u5e03\u5c40\u5e76\u4e0d\u4ef6\u6613\u4e8b\uff0c\u672c\u6559\u7a0b\u5c06\u7740\u91cd\u5206\u6790\u51fa\u73b0\u5728\u591a\u5217\u5e03\u5c40\u7684\u591a\u4e2a\u95ee\u9898\uff0c\u7136\u540e\u4e3a\u5927\u5bb6\u7b49\u6765\u4e00\u4e2a\u7b80\u5355\u5168\u6e38\u89c8\u5668\u901a\u5403\u7684\u89e3\u51b3\u65b9\u6cd5\uff0c\u4e0d\u4f7f\u7528\u56fe\u7247\uff0c\u811a\u672c\uff0cCSS hacks\u5e76\u5728\u6700\u4e25\u683c\u7684XHTML \u89c4\u8303\u4e2d\u90fd\u80fd\u901a\u8fc7\u9a8c\u8bc1\u3002<!--more--><\/p>\n<h3>\u95ee\u9898\u7684\u75c7\u7ed3\u6240\u5728<\/h3>\n<p><a href=\"http:\/\/i.imgur.com\/292RZ.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"problem\" src=\"http:\/\/i.imgur.com\/292RZ.gif\" alt=\"\" width=\"450\" height=\"250\" \/><\/a><\/p>\n<p>\u5982\u4e0a\u56fe\u6240\u793a\uff0c\u7531\u4e8e\u5404\u5217\u7684\u5185\u5bb9\u4e0d\u4e00\u81f4\u5bfc\u81f4\u5176\u80cc\u666f\u7684\u9ad8\u5ea6\u4e5f\u4e0d\u7edf\u4e00\u3002\u800c\u80cc\u666f\u5b9e\u8d28\u4e0a\u662f\u5185\u5bb9\uff08\u6807\u51c6\u7684\u76d2\u5b50\u6a21\u578b\u662f\u7531\u5185\u5bb9\u533a\uff0c\u8865\u767d\u533a\u00a0\uff0c\u8fb9\u6846\u533a\u4e0e\u8fb9\u754c\u533a\u7ec4\u6210\uff0c\u80cc\u666f\u5b58\u5728\u4e8e\u524d\u4e09\u8005\u4e2d\uff1bIE\u4e3a\u524d\u4e24\u8005\uff09\u7684\u81ea\u9002\u5e94\u7684\u95ee\u9898\u3002\u518d\u8f6c\u5316\u4e00\u4e0b\uff0c\u5982\u4f55\u6491\u5927\u90a3\u4e9b\u8f83\u77ed\u7684\u5217\u7684\u9ad8\u5ea6\uff0c\u8ba9\u6240\u6709\u5217\u7684\u9ad8\u5ea6\u7b49\u4e8e\u6700\u9ad8\u7684\u5217\u7684\u9ad8\u5ea6\uff1f\u8fd9\u4e2a\uff0c\u7684\u786e\u5f88\u5f88\u68d8\u624b\uff0c\u56e0\u4e3a\u6211\u4eec\u4e0d\u6e05\u695a\u5404\u5217\u7684\u9ad8\u5ea6\uff0c\u4e5f\u65e0\u4ece\u5f97\u77e5\u54ea\u4e00\u5217\u6700\u9ad8\u3002\u6211\u4eec\u4e5f\u4e0d\u80fd\u7b80\u5355\u5730\u7ed9\u6240\u6709\u5217\u4e00\u4e2a\u660e\u786e\u7684\u9ad8\u5ea6\uff0c\u8fd9\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6240\u6709\u5217\u90fd\u591a\u51fa\u4e00\u5927\u7247\u7a7a\u767d\uff0c\u6216\u8005\u5f88\u4e0d\u4e8f\u7531\u4e8e\u9ad8\u5ea6\u4e0d\u8db3\u5bfc\u81f4\u67d0\u4e9b\u5217\u7684\u5185\u5bb9\u65e0\u6cd5\u5168\u90e8\u663e\u793a\u51fa\u6765\uff01\u73b0\u5b9e\u4e2d\uff0c\u5185\u5bb9\u7684\u957f\u5ea6\u662f\u52a8\u6001\u7684\uff0c\u56e0\u6b64\u6bcf\u5217\u7684\u9ad8\u5ea6\u4e5f\u662f\u52a8\u6001\u7684\u3002\u6211\u4eec\u5fc5\u987b\u610f\u8bc6\u5230\u5728\u7f51\u7edc\u4e2d\uff0c\u4e0d\u5b58\u5728\u201d\u56fa\u5b9a\u201c\u4e8c\u5b57\uff0c\u6bcf\u4e2a\u4eba\u7684\u663e\u793a\u5668\u7684\u5206\u8fa9\u7387\u90fd\u4e0d\u5c3d\u4e00\u6837\uff0c\u6e38\u89c8\u5668\u7684\u5b57\u4f53\u5927\u5c0f\u8bbe\u7f6e\u4e5f\u4e0d\u5c3d\u76f8\u540c\uff0c\u8fd9\u4e9b\u90fd\u4f1a\u5f71\u54cd\u5230\u5185\u5bb9\u7684\u663e\u793a\u9ad8\u5ea6\u3002<\/p>\n<h3>\u5bf9\u5185\u5bb9\u4e0e\u80cc\u666f\u5b9e\u884c\u5206\u79bb<\/h3>\n<p>\u89e3\u51b3\u7b49\u9ad8\u95ee\u9898\u7684\u7b2c\u4e00\u6b65\u5c31\u662f\u628a\u5b83\u62c6\u5206\u4e3a\u4e24\u4e2a\u8f83\u5c0f\u7684\uff0c\u53ef\u4ee5\u5355\u72ec\u89e3\u51b3\u7684\u90e8\u5206\u3002\u8fd9\u6837\uff0c\u6211\u4eec\u539f\u6765\u662f\u4e00\u5217\u5bf9\u5e94\u4e00\u4e2aDIV\uff0c\u73b0\u5728\u662f\u4e00\u5217\u5bf9\u5e94\u4e00\u4e2aDIV\uff0c\u4e00\u4e2a\u7528\u6765\u88c5\u8f7d\u5185\u5bb9\uff0c\u4e00\u4e2a\u7528\u6765\u663e\u793a\u80cc\u666f\u3002\u8fd9\u79cd\u5206\u79bb\u6709\u5229\u4e8e\u6211\u4eec\u5bf9\u5404\u4e2a\u5143\u7d20\u7684\u638c\u63a7\u548c\u628a\u5b83\u4eec\u7528\u53e6\u4e00\u79cd\u66f4\u6709\u6548\u7684\u65b9\u5f0f\u7ec4\u5408\u8d77\u6765\uff0c\u8fd9\u5f15\u8d77\u6211\u5f88\u5feb\u4f1a\u5728\u4e0b\u9762\u7684\u7ae0\u8282\u8bb2\u8ff0\u3002<\/p>\n<h3>\u5229\u7528\u6d6e\u52a8\u5d4c\u5957\u89e3\u51b3\u6700\u9ad8\u5217\u7684\u9ad8\u5ea6\u7684\u95ee\u9898<\/h3>\n<p>\u8fd9\u662f\u89e3\u51b3\u591a\u5217\u7b49\u9ad8\u7684\u5173\u952e\u3002\u4f7f\u4e00\u4e2aDIV\u7684\u9ad8\u5ea6\u7b49\u4e8e\u6700\u9ad8\u5217\u7684\u9ad8\u5ea6\u7684\u552f\u4e00\u65b9\u6cd5\u5c31\u662f\u8ba9\u8fd9\u4e2aDIV\u5305\u542b\u6240\u6709\u7684\u5217\u3002\u6362\u53e5\u8bdd\u8bf4\uff0c\u901a\u8fc7\u628a\u6240\u6709\u7684\u5217\u653e\u5728\u4e00\u4e2a\u5bb9\u5668\u4e2d\uff0c\u5bb9\u5668\u7684\u9ad8\u5ea6\u5c31\u662f\u6700\u9ad8\u5217\u7684\u9ad8\u5ea6\u3002\u8fd9\u662f\u4e2a\u975e\u5e38\u6709\u7528\u7684\u7ed3\u6784\u3002<br \/>\n<a href=\"http:\/\/i.imgur.com\/AojKm.gif\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" title=\"div container\" src=\"http:\/\/i.imgur.com\/AojKm.gif\" alt=\"\" width=\"300\" height=\"194\" \/><\/a><\/p>\n<h4>\u5355\u884c\u4e09\u5217\u7684\u5e03\u5c40\u7684\u7ed3\u6784\u5c42\u4ee3\u7801<\/h4>\n<pre lang=\"html4strict\">\n<div id=\"container1\">\n<div id=\"col1\">Column 1<\/div>\n<div id=\"col2\">Column 2<\/div>\n<div id=\"col3\">Column 3<\/div>\n<\/div>\n<\/pre>\n<h4>\u5bf9\u5e94\u7684\u8868\u73b0\u5c42\u4ee3\u7801<\/h4>\n<pre lang=\"css\">\n#container1 { \nfloat:left; \nwidth:100%; \n} \n#col1 { \nfloat:left; \nwidth:30%; \nbackground:red; \n} \n#col2 { \nfloat:left; \nwidth:40%; \nbackground:yellow; \n} \n#col3 { \nfloat:left; \nwidth:30%; \nbackground:green; \n} \n<\/pre>\n<p>\u4e3a\u4e86\u4f7f\u7528\u8fd9\u79cd\u7ed3\u6784\u5728\u6240\u6709\u6e38\u89c8\u5668\u90fd\u6b63\u5e38\u5de5\u4f5c\uff0c\u6211\u4eec\u5fc5\u987b\u8ba9\u5916\u5c42\u5bb9\u5668\u5f80\u5de6\u6216\u53f3\u6d6e\u52a8\uff0c\u5e76\u4e14\u5176\u5b50\u5143\u7d20\u5305\u542b\u6bcf\u4e00\u680f\u5185\u5bb9\u7684DIV\u4e5f\u8ddf\u7740\u6d6e\u52a8\uff0c\u54ea\u4e00\u4e2a\u65b9\u5411\u90fd\u65e0\u6240\u8c13\u3002\u6d6e\u52a8\u4f1a\u4f7f\u7528\u5b83\u4eec\u5f80\u4e0a\u5bf9\u9f50\u4e8e\u5916\u56f4\u5bb9\u5668\u7684\u4e0a\u8865\u767d\uff0c\u5e76\u4e14\u6d6e\u52a8\u7684\u5bb9\u5668\u4f1a\u81ea\u52a8\u8c03\u6574\u81ea\u8eab\u7684\u9ad8\u5ea6\u4e0e\u5bbd\u5ea6\u4ee5\u5b9e\u73b0\u5bf9\u6d6e\u52a8\u5b50\u5143\u7d20\u7684\u5305\u542b\u3002\u4f46\u662f\u5982\u679c\u5bb9\u5668\u88ab\u5b9a\u4e49\u4e86\u9ad8\u5ea6\u4e0e\u5bbd\u5ea6\uff0c\u5219\u5b83\u4e0d\u4f1a\u968f\u5b50\u5143\u7d20\u7684\u5927\u5c0f\u800c\u81ea\u52a8\u8c03\u6574\u81ea\u8eab\u663e\u793a\u533a\u57df\u6765\u9002\u5e94\u5b50\u5143\u7d20\u7684\u663e\u793a\u3002\u4f46\u5728IE6\u4e0e\u4f4e\u7248\u672c\u7684IE\u4e2d\uff0c\u5b50\u6d6e\u52a8\u5143\u7d20\u80fd\u6491\u5f00\u5916\u56f4\u5143\u7d20\uff1b\u5e78\u597dIE7\u4e0eIE8\u5df2\u5f15\u6b63\u4e86\u8fd9\u4e2a\u4e0d\u7b26\u5408\u6807\u51c6\u7684\u505a\u6cd5\u3002 <\/p>\n<h3>\u589e\u52a0\u7528\u6765\u663e\u793a\u80cc\u666f\u7684\u5bb9\u5668<\/h3>\n<p>\u4e0b\u4e00\u6b65\u662f\u589e\u52a0\u989d\u5916\u7684\u5bb9\u5668\uff0c\u8ba9\u5b83\u4eec\u5f7c\u6b64\u5d4c\u5957\uff0c\u5e76\u8ba9\u6240\u6709\u5916\u56f4\u7684\u5bb9\u5668\u6570\uff08\u65b0\u589e\u7684\u52a0\u4e0a\u539f\u6765\u7684\u90a3\u4e00\u4e2a\uff09\u7b49\u4e8e\u5217\u7684\u603b\u6570\uff1a3\u3002\u8fd9\u4e09\u4e2a\u5bb9\u5668\u7528\u6765\u663e\u793a\u5404\u5217\u7684\u80cc\u666f\u3002\u8bf7\u6ce8\u610f\uff0c\u6211\u4eec\u53bb\u6389\u4e86\u539f\u6765\u5404\u5217\u7684\u80cc\u666f\uff0c\u628a\u5b83\u4eec\u79fb\u81f3\u8fd9\u4e9b\u5bb9\u5668\u4e0a\u3002<br \/>\n<a href=\"http:\/\/i.imgur.com\/dlo9y.gif\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/i.imgur.com\/dlo9y.gif\" title=\"div height\" class=\"aligncenter\" width=\"350\" height=\"205\" \/><\/a><\/p>\n<h4>\u65b0\u7684\u7ed3\u6784\u5c42\u4ee3\u7801\uff0c\u8ba9\u65b0\u589e\u7684\u5bb9\u5668\u5957\u5728\u539f\u6765\u7684\u5916\u56f4\u5bb9\u5668\u4e0a<\/h4>\n<pre lang=\"html4strict\">\n<div id=\"container3\"> \n<div id=\"container2\"> \n<div id=\"container1\"> \n<div id=\"col1\">Column 1<\/div> \n<div id=\"col2\">Column 2<\/div> \n<div id=\"col3\">Column 3<\/div> \n<\/div> \n<\/div> \n<\/div> \n<\/pre>\n<h4>\u65b0\u7684\u8868\u73b0\u5c42\u4ee3\u7801\uff0c\u65b0\u589e\u7684\u5bb9\u5668\u90fd\u662f\u6d6e\u52a8\u5143\u7d20<\/h4>\n<p>\u6240\u6709\u5143\u7d20\u5de6\u6d6e\u52a8\uff0c\u5c06\u5bb9\u5668\u5bbd\u5ea6\u8bbe\u4e3a100%\uff0c\u4f7f\u4ed6\u4eec\u5360\u6ee1\u9875\u9762\u7684\u5bbd\u5ea6\u3002\u80cc\u666f\u8272\u4ece\u5185\u5bb9 div \u79fb\u9664\u5e76\u52a0\u81f3\u5bb9\u5668\u4e0a\u3002\u6ce8\uff0c\u539f\u6587\u662f\u6240\u6709\u5bb9\u5668\u7684\u5bbd\u90fd\u8bbe\u4e3a100%\uff0c\u5176\u5b9e\u6839\u672c\u6ca1\u6709\u8fd9\u6837\u7684\u5fc5\u987b\uff0c\u56e0\u4e3a\u5728\u6d6e\u52a8\u5d4c\u5957\u4e2d\uff0c\u5916\u9762\u7684\u5bb9\u5668\u5fc5\u987b\u4f1a\u88ab\u6491\u5927\u80fd\u5bb9\u5f97\u4e0b\u5185\u90e8\u5b50\u5143\u7d20\u7684\u5927\u5c0f\uff01 <\/p>\n<pre lang=\"css\">\n#container3 { \nfloat:left; \n\/*width:100%;*\/ \nbackground:green; \n} \n#container2 { \nfloat:left; \n\/*width:100%;*\/ \nbackground:yellow; \n} \n#container1 { \nfloat:left; \nwidth:100%; \nbackground:red; \n} \n#col1 { \nfloat:left; \nwidth:30%; \n} \n#col2 { \nfloat:left; \nwidth:40%; \n} \n#col3 { \nfloat:left; \nwidth:30%; \n} <\/pre>\n<h3>\u7528\u76f8\u5bf9\u5b9a\u4f4d\u6765\u79fb\u52a8\u5bb9\u5668<\/h3>\n<p>\u73b0\u5728\u662f\u6240\u6709\u5bb9\u5668\u90fd\u5b8c\u7f8e\u5730\u7d2f\u5728\u4e00\u8d77\uff0c\u53ea\u663e\u793a\u4e00\u79cd\u80cc\u666f\u989c\u8272\uff0c\u6211\u4eec\u5fc5\u987b\u8ba9\u5176\u4ed6\u80cc\u666f\u4e5f\u663e\u793a\u51fa\u6765\u3002\u4e3a\u6b64\u6211\u4eec\u5c31\u5f97\u5229\u7528\u76f8\u5bf9\u5b9a\u4f4d\u6765\u8ba9\u8fd9\u4e9b\u5bb9\u5668\u50cf\u9636\u68af\u4e00\u6837\u653e\u7f6e\u3002\u8fd9\u4e2a\u672c\u53ef\u4ee5\u4f7f\u7528\u8d1f\u8fb9\u754c\u6280\u672f\uff0c\u4f46\u8be5\u6b7b\u7684IE5.5\u7684\u76d2\u5b50\u6a21\u578b\u4e0eW3C\u7684\u4e0d\u4e00\u81f4\uff0c\u4e3a\u4e86\u517c\u5bb9\u6211\u4eec\u5c31\u5f97\u4f7f\u7528\u5230CSS hack\u3002\u7531\u4e8e\u672c\u6587\u58f0\u660e\u662f\u4e0d\u4f7f\u7528CSS hack\uff0c\u56e0\u6b64\u653e\u5f03\u3002\u9996\u5148\u8ba9#container2\u5411\u53f3\u79fb\u523030%,\u7531\u4e8e#container2\u88c5\u7740#container1\uff0c\u800c#container1\u4e0a\u88c5\u7740\u90a3\u4e09\u4e2a\u5217\uff0c\u8fd9\u6837\u4e00\u6765\uff0c\u6700\u53f3\u8fb9\u7684\u5217\u5c31\u88ab\u79fb\u51fa\u6e38\u89c8\u5668\u7684\u53f3\u8fb9\u4e86\u3002\u800c\u6700\u5916\u56f4\u6700\u5e95\u5c42\u7684\u5bb9\u5668#container3\u5219\u9732\u51fa\u6765\u4e86\uff0c\u9732\u4e86\u5de6\u8fb9\u768430%\u3002\u7136\u540e\u6211\u4eec\u518d\u79fb\u52a8\u6700\u4e0a\u5c42\u7684\u5bb9\u5668#container1\uff0c\u5411\u53f3\u8fb9\u79fb\u52a840%\uff0c\u4e8e\u662f\u539f\u6765\u76d6\u4f4f\u7684\u7b2c\u4e8c\u5c42\u5bb9\u5668\u4e5f\u9732\u51fa\u6765\u4e86\uff0c\u9732\u51fa\u5176\u5de6\u8fb9\u768440%,\u800c#container1\u5219\u53ea\u5269\u4e0b100%-30%-40%=30%;\u4e0a\u65b9\u7684\u5217\u4e5f\u53ea\u5269\u4e0b\u6700\u53f3\u8fb9\u7684\u5217\uff0c\u5374\u8868\u73b0\u4e3a\u4f4d\u4e8e\u6700\u5de6\u8fb9\u3002\u8fd9\u6837\uff0c\u80cc\u666f\u4e5f\u663e\u793a\u6b63\u5e38\u4e86\uff01<br \/>\n<a href=\"http:\/\/i.imgur.com\/K18AP.gif\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/i.imgur.com\/K18AP.gif\" title=\"move the div\" class=\"aligncenter\" width=\"497\" height=\"632\" \/><\/a><\/p>\n<h4>\u5bf9\u5e94\u7684\u8868\u73b0\u5c42\u4ee3\u7801<\/h4>\n<pre lang=\"css\">\n#container3 { \nfloat:left; \n\/*width:100%;*\/\n\/*\u6ca1\u6709\u5fc5\u8981\u7684\u4ee3\u7801\u88ab\u6ce8\u91ca\u6389\uff01*\/\nbackground:green; \n} \n#container2 { \nfloat:left; \n\/*width:100%;*\/\n\/*\u6ca1\u6709\u5fc5\u8981\u7684\u4ee3\u7801\u88ab\u6ce8\u91ca\u6389\uff01*\/\nbackground:yellow; \nposition:relative; \nright:30%; \n} \n#container1 { \nfloat:left; \nwidth:100%; \nbackground:red; \nposition:relative; \nright:40%; \n} \n#col1 { \nfloat:left; \nwidth:30%; \n} \n#col2 { \nfloat:left; \nwidth:40%; \n} \n#col3 { \nfloat:left; \nwidth:30%; \n}\n<\/pre>\n<h4>\u628a\u5404\u5217\u7684\u5185\u5bb9\u79fb\u56de\u539f\u6765\u7684\u4f4d\u7f6e\u4e0a<\/h4>\n<p>\u7531\u4e8e\u6700\u4e0a\u5c42\u7684\u90a3\u4e09\u5217\u90fd\u662f\u88ab\u6574\u4f53\u5f80\u53f3\u5f80\u5230(\u9875\u9762\u7684)70%\uff0c\u6211\u4eec\u518d\u628a\u5b83\u4eec\u90fd\u5f80\u5de6\u79fb\u56de70%\u5c31\u662f\uff01\u6700\u540e\uff0c\u7531\u4e8e\u6211\u4eec\u524d\u4e24\u4e2a\u80cc\u666f\u5bb9\u5668\u90fd\u662f\u88ab\u5411\u53f3\u79fb\u52a8\uff0c\u79fb\u51fa\u4e86\u6e38\u89c8\u5668\uff0c\u5b83\u4eec\u90fd\u4e0e\u6e38\u89c8\u5668\u7684\u53f3\u8fb9\u8fde\u5728\u4e00\u8d77\uff0c\u6211\u4eec\u53ef\u4ee5\u8bbe\u7f6e\u6700\u5e95\u5c42\u7684\u80cc\u666f\u5bb9\u5668\u7684overflow\u6765\u9690\u85cf\u90a3\u4e9b\u88ab\u79fb\u51fa\u7684\u90e8\u5206\u3002<\/p>\n<pre lang=\"css\">#container3 { \nfloat:left; \n\/*width:100%;*\/\n\/*\u6ca1\u6709\u5fc5\u8981\u7684\u4ee3\u7801\u88ab\u6ce8\u91ca\u6389\uff01*\/\nbackground:green; \noverflow:hidden; \nposition:relative; \n} \n#container2 { \nfloat:left; \n\/*width:100%;*\/\n\/*\u6ca1\u6709\u5fc5\u8981\u7684\u4ee3\u7801\u88ab\u6ce8\u91ca\u6389\uff01*\/\nbackground:yellow; \nposition:relative; \nright:30%; \n} \n#container1 { \nfloat:left; \nwidth:100%; \nbackground:red; \nposition:relative; \nright:40%; \n} \n#col1 { \nfloat:left; \nwidth:30%; \nposition:relative; \nleft:70%; \n} \n#col2 { \nfloat:left; \nwidth:40%; \nposition:relative; \nleft:70%; \n} \n#col3 { \nfloat:left; \nwidth:30%; \nposition:relative; \nleft:70%; \n}<\/pre>\n<h4>\u5bf9\u5217\u6dfb\u52a0\u8865\u767d\uff08\u5185\u8fb9\u8ddd\uff09<\/h4>\n<p>\u6700\u540e\uff0c\u6211\u4eec\u5bf9\u5217\u589e\u52a0\u8865\u767d\uff0c\u8ba9\u6bcf\u5217\u663e\u5f97\u5927\u65b9\u4e00\u4e9b\uff0c\u800c\u4e0d\u662f\u5bc6\u5bc6\u9ebb\u9ebb\u5730\u585e\u6ee1\u4e00\u5217\u3002\u4f46\u662f\u5982\u679c\u6211\u4eec\u589e\u52a0\u8865\u767d\uff0c\u53ef\u80fd\u6709\u4e00\u4e9b\u6e38\u89c8\u5668\u7684\u6709\u75c5\u53c8\u72af\u4e86\uff0c\u5728IE6\u548c\u66f4\u4f4e\u7248\u672c\u7684IE\u4e2d\uff0c\u5176\u602a\u5f02\u7684\u76d2\u5b50\u6a21\u578b\uff0c\u4f1a\u4ea7\u751f\u4e00\u4e9b\u6211\u4eec\u4e0d\u613f\u770b\u5230\u7684\u7ed3\u679c\u3002\u5982\uff0c\u4e00\u4e2a 200px \u5bbd 20px \u8865\u767d\u7684 box \u5728 IE \u4e2d\u88ab\u89c6\u4e3a 200px \u5bbd\uff0c\u5728\u5176\u4ed6\u6d4f\u89c8\u5668\u4e2d\u5219\u4e3a\u6b63\u786e\u7684 240px\u3002\u8865\u767d\u5e94\u8be5\u52a0\u5728\u5143\u7d20\u7684\u5bbd\u5ea6\u4e0a\u3002<br \/>\n\u4e0d\u8fc7\u653e\u5fc3\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u5b8c\u5168\u4e0d\u4f9d\u8d56\u4e8e padding \u7684\u65b9\u6cd5\u6765\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002\u76f8\u53cd\uff0c\u6211\u4eec\u628a\u5217\u5f04\u7a84\u4e00\u70b9\uff08\u5217\u5bbd\u51cf\u53bb\u4e24\u4fa7\u7684\u8865\u767d\uff09\uff0c\u4e4b\u540e\u7528\u76f8\u5bf9\u5b9a\u4f4d\u628a\u5b83\u4eec\u79fb\u81f3\u6b63\u786e\u7684\u4f4d\u7f6e\u3002\u4f8b\u5982\uff0c\u6211\u4eec\u7528\u4e86 2% \u7684\u8865\u767d\uff0c\u5219 30% \u7684\u5217\u5c06\u51cf\u81f3 26%\uff0c40% \u7684\u5217\u51cf\u81f3 36%\u3002\u7528\u76f8\u5bf9\u5b9a\u4f4d\u79fb\u56de\u5217\u65f6\u9700\u8c28\u8bb0\uff0c\u73b0\u5728\u5217\u53d8\u7a84\u4e86\uff0c\u6240\u4ee5\u5f53\u5b83\u4eec\u4e00\u8d77\u50cf\u6700\u521d\u90a3\u6837\u5de6\u6d6e\u52a8\u65f6\uff0c\u6bcf\u4e00\u4e2a\u9700\u8981\u6bd4\u4e0a\u4e00\u4e2a\u79fb\u52a8\u66f4\u8fdc\u7684\u8ddd\u79bb\u3002<br \/>\n<a href=\"http:\/\/i.imgur.com\/oKFoM.gif\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" src=\"http:\/\/i.imgur.com\/oKFoM.gif\" title=\"inner space\" class=\"aligncenter\" width=\"351\" height=\"193\" \/><\/a><\/p>\n<h4>\u5b8c\u6574\u7684CSS<\/h4>\n<pre lang=\"css\" line=\"\" file=\"\" colla=\"+\">#container3 { \nfloat:left; \nbackground:green; \noverflow:hidden; \nposition:relative; \n} \n#container2 { \nfloat:left; \nbackground:yellow; \nposition:relative; \nright:30%; \n} \n#container1 { \nfloat:left; \nwidth:100%; \nbackground:red; \nposition:relative; \nright:40%; \n} \n#col1 { \nfloat:left; \nwidth:26%; \nposition:relative; \nleft:72%; \noverflow:hidden; \n} \n#col2 { \nfloat:left; \nwidth:36%; \nposition:relative; \nleft:76%; \noverflow:hidden; \n} \n#col3 { \nfloat:left; \nwidth:26%; \nposition:relative; \nleft:80%; \noverflow:hidden; \n}<\/pre>\n<p>\u597d\u4e86\uff0c\u6587\u7ae0\u5c31\u6b64\u7ed3\u679c\uff0c\u66f4\u591a\u7684\u4f8b\u5b50\u53ef\u4ee5\u53c2\u770b<a href=\"http:\/\/matthewjamestaylor.com\/blog\/equal-height-columns-cross-browser-css-no-hacks\">\u539f\u4f5c\u8005\u7684\u7f51\u5740<\/a>\uff0c\u6216\u70b9\u51fb\u4ee5\u4e0b\u94fe\u63a5\uff1a<a href=\"http:\/\/matthewjamestaylor.com\/blog\/equal-height-columns-2-column.htm\">2 \u5217\u00a0<\/a>\uff0c\u00a0<a href=\"http:\/\/matthewjamestaylor.com\/blog\/equal-height-columns-3-column.htm\">3 \u5217<\/a>\uff0c\u00a0<a href=\"http:\/\/matthewjamestaylor.com\/blog\/equal-height-columns-4-column.htm\">4 \u5217<\/a>\uff0c\u4ee5\u53ca<a href=\"http:\/\/matthewjamestaylor.com\/blog\/equal-height-columns-5-column.htm\">5 \u5217<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8bf4\u660e: \u539f\u6587\u7ffb\u8bd1\u81eaMatthew James Taylor\u7684Equal Heig &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"more-link\" href=\"https:\/\/lttt.vanabel.cn\/?p=2224\"> <span class=\"screen-reader-text\">[\u8f6c\u8f7d]\u7eafCSS\u65e0hacks\u7684\u8de8\u6e38\u89c8\u5668\u81ea\u9002\u5e94\u9ad8\u5ea6\u591a\u5217\u5e03\u5c40<\/span> \u9605\u8bfb\u66f4\u591a &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[272,71,296,302,456,425],"class_list":["post-2224","post","type-post","status-publish","format-standard","hentry","category-admin","tag-css","tag-71","tag-wp-tec","tag-302","tag-456","tag-425"],"_links":{"self":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/2224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2224"}],"version-history":[{"count":0,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=\/wp\/v2\/posts\/2224\/revisions"}],"wp:attachment":[{"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lttt.vanabel.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}