{"id":629,"date":"2010-02-05T08:50:19","date_gmt":"2010-02-05T00:50:19","guid":{"rendered":"http:\/\/www.zhangxinxu.com\/wordpress\/?p=629"},"modified":"2018-01-01T15:14:58","modified_gmt":"2018-01-01T07:14:58","slug":"%e5%8e%bb%e9%99%a4%e5%86%97%e4%bd%99-%e7%b2%be%e7%ae%80%e6%82%a8%e7%9a%84css%e6%a0%b7%e5%bc%8f%e4%bb%a3%e7%a0%81","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2010\/02\/%e5%8e%bb%e9%99%a4%e5%86%97%e4%bd%99-%e7%b2%be%e7%ae%80%e6%82%a8%e7%9a%84css%e6%a0%b7%e5%bc%8f%e4%bb%a3%e7%a0%81\/","title":{"rendered":"\u53bb\u9664\u5197\u4f59 &#8211; \u7cbe\u7b80\u60a8\u7684CSS\u6837\u5f0f\u4ee3\u7801"},"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=629\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=629<\/a><\/p>\n<h3>\u4e00\u3001\u524d\u9762\u7b80\u77ed\u7684\u5520\u53e8<\/h3>\n<p>\u6211\u6382\u91cf\u4e86\u4e0b\uff0c\u672c\u6587\u8fd8\u662f\u6709\u4e9b\u5fc5\u8981\u7684\u3002\u8bb2\u8bb2\u5e38\u89c1\u7684\u4e00\u4e9b\u6ca1\u6709\u5fc5\u8981\u4f7f\u7528CSS\u4ee3\u7801\u60c5\u51b5\uff0c\u800c\u8fd9\u4e9b\u4e0d\u8d77\u4f5c\u7528\u53ef\u4ee5\u53bb\u6389\u7684CSS\u4ee3\u7801\u53ef\u80fd\u662f\u6211\u4eec\u7ecf\u5e38\u5ffd\u89c6\u7684\u3002\u8d8a\u662f\u5bf9CSS\u7406\u89e3\u4e0d\u591f\uff0c\u8d8a\u5bb9\u6613\u51fa\u73b0\u8fd9\u4e9b\u95ee\u9898\u3002<\/p>\n<p>\u6709\u5fc5\u8981\u8bf4\u660e\u4e0b\uff0c\u672c\u6587\u7684\u6837\u5f0f\u4ee3\u7801\u5747\u4e0d\u8003\u8651\u7ee7\u627f\u6216\u662f<a target=\"_blank\" class=\"a_link\" href=\"http:\/\/www.zhangxinxu.com\/study\/200912\/css-tools-css-reset.html\">CSS reset<\/a>\u3002<\/p>\n<h3>\u4e8c\u3001\u4e00\u4e9b\u5e38\u89c1\u4e0d\u5fc5\u8981CSS\u6837\u5f0f<\/h3>\n<h4>1\u3001\u4e0e\u9ed8\u8ba4CSS\u6837\u5f0f\u4e00\u81f4<\/h4>\n<p>\u6211\u4eec\u6709\u65f6\u5019\u5199\u7684CSS\u6837\u5f0f\u4f1a\u4e0e\u6d4f\u89c8\u5668\u9ed8\u8ba4\u7684CSS\u6837\u5f0f\u4e00\u81f4\uff0c\u6709\u65f6\u5019\u60a8\u81ea\u5df1\u90fd\u53ef\u80fd\u6ca1\u6709\u610f\u8bc6\u5230\u3002<\/p>\n<p>\u5e38\u89c1\u7684\u4f8b\u5b50\u6709\uff1a<\/p>\n<ol>\n<li>\n<pre>div{<del datetime=\"2010-02-04T23:43:40+00:00\">width:auto;<\/del> <del datetime=\"2010-02-04T23:43:40+00:00\">height:auto;<\/del>}<\/pre>\n<p>\u5bf9\u4e8e\u4e00\u4e9b\u521a\u4f7f\u7528CSS\u7684\u7ae5\u978b\uff0c\u6709\u65f6\u5019\uff0c\u5176\u4e3a\u4e86\u8868\u8fbe\u8fd9\u6bb5div\u9ad8\u5ea6\u662f\u81ea\u52a8\u9002\u5e94\u4e8e\u5185\u90e8\u5143\u7d20\u7684\uff0c\u4f1a\u60c5\u4e0d\u81ea\u7981\u7684\u52a0\u4e0a<code>height:auto;<\/code>\u7684\u6837\u5f0f\u3002\u5f88\u663e\u7136\uff0c\u8fd9\u6bb5\u6837\u5f0f\u662f\u6ca1\u6709\u5fc5\u8981\u7684\uff0c\u9ed8\u8ba4\u7684\u4efb\u4f55\u5757\u72b6\u5143\u7d20\u7684\u9ad8\u5ea6\u51e0\u4e4e\u90fd\u662fauto\u3002<br \/>\n\u6211\u4eec\u6765\u770b\u770b\u4eba\u4eba\u7f51\u4e2a\u4eba\u9996\u9875\u7684CSS\u6837\u5f0f\u6587\u4ef6\uff08\u94fe\u63a5\u70b9<a href=\"http:\/\/s.xnimg.cn\/a6807\/csspro\/apps\/home-all.css\">\u8fd9\u91cc<\/a>\uff09\uff0c\u6211\u5728chrome\u6d4f\u89c8\u5668\u4e0bCtrl+F\u641c\u7d22height:auto\uff0c\u5c45\u7136\u663e\u793a\u4e86\u4e5d\u6761\uff08\u89c1\u4e0b\u56fe\uff09\u3002<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"\u4eba\u4eba\u7f519\u4e2aheight:auto\u6837\u5f0f\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_044821.png\" title=\"\u4eba\u4eba\u7f519\u4e2aheight:auto\u6837\u5f0f \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" class=\"alignnone\" width=\"356\" height=\"44\" \/><br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"\u51fa\u73b0\u7684height:auto\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_045250.png\" title=\"\u51fa\u73b0\u7684height:auto \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" class=\"alignnone\" width=\"553\" height=\"47\" \/><\/p>\n<p>\u6309\u7167\u5e38\u89c4\u6765\u8bb2\uff0cheight:auto\u53ea\u6709\u5728\u4f7f\u7528CSS\u4f18\u5148\u7ea7\u62b9\u6389\u4e4b\u524d\u7684height\u5b9a\u503c\u7684\u6837\u5f0f\u7684\u65f6\u5019\u4f7f\u7528\uff0c\u5176\u4f59\u60c5\u51b5\u57fa\u672c\u4e0a\u90fd\u662f\u53ef\u4ee5\u53bb\u6389\u7684\u3002\u5c31\u50cf\u662f\u4e0a\u9762\u4eba\u4eba\u7f51\u7684\u4f8b\u5b50\uff0c\u5c45\u71369\u4e2aheight:auto\uff0c\u6211\u6562\u80af\u5b9a\u81f3\u5c11\u6709\u4e00\u534a\u662f\u6ca1\u6709\u5fc5\u8981\u7684\u3002<\/li>\n<li>\n<pre>\nbody,p,h1,h2,h3,h4,h5,h6{margin:0; <del datetime=\"2010-02-04T23:43:40+00:00\">padding:0;<\/del>}\n<\/pre>\n<p>\u4e0a\u9762\u6709\u5173body,p\u7b49\u6807\u7b7e\u7684\u6837\u5f0f\u4e2d\u6709\u4e2a\u6837\u5f0f\u662f\u65e0\u6548\u7684\uff0c\u4e0e\u9ed8\u8ba4\u503c\u4e00\u81f4\u7684\uff0c\u8fd9\u4e2a\u6837\u5f0f\u5c31\u662f<code>padding:0;<\/code>\uff0c\u5bf9\u4e8ebody,p,h1~6\u8fd9\u4e9b\u6807\u7b7e\uff0c\u672c\u8eab\u7684padding\u503c\u5c31\u662f0\uff0c\u6240\u4ee5\u53ea\u9700\u8981margin:0\u5c31\u53ef\u4ee5\u4e86\u3002<\/p>\n<p>\u5728CSS reset\u4e2d\uff0c\u4e3a\u4e86\u65b9\u4fbf\uff0c\u90fd\u662f\u4e00\u5806\u6807\u7b7e\u76f4\u63a5\u5957\u4e2a<code>margin:0;padding:0;<\/code>\u4e86\u4e8b\u3002\u8fd8\u62ff\u4eba\u4eba\u7f51\u7684CSS\u6837\u5f0f\u6587\u4ef6\u4e3e\u4f8b\uff0c\u4eba\u4eba\u7f51\u4e2a\u4eba\u9996\u9875\u6837\u5f0f\u7b2c\u4e00\u884c\u5c31\u662f\u4e00\u957f\u4e32\u6807\u7b7e\u5e26\u4e2a<code>margin:0;padding:0;<\/code>\u5148\u4e0d\u7ba1\u5176\u72af\u50bb\u628aspan,div,em\u4e4b\u7c7b\u7684\u6807\u7b7e\u4e5f\u52a0\u8fdb\u5165\uff0c\u5c31\u7b97\u662f\u6ca1\u6709\u8fd9\u4e9b\u6807\u7b7e\uff0c\u6211\u4e5f\u662f\u6781\u4e0d\u63a8\u8350\u8fd9\u79cd\u5199\u6cd5\uff0c\u5b8c\u5168\u7684\u6d6a\u8d39\u8d44\u6e90\uff0c\u6d6a\u8d39CSS\u7684\u6e32\u67d3\u3002\u6211\u6bd4\u8f83\u559c\u6b22\u7684\u505a\u6cd5\u662f\u628aul,ol\u72ec\u7acb\u51fa\u6765\uff0c\u56e0\u4e3aul,ol\u8fd8\u8981\u72ec\u7acb\u8bbe\u7f6elist-style\u6837\u5f0f\uff0c\u800c\u4e14\u5e38\u7528\u7684\u6807\u7b7e\u5c31ul,ol\u5217\u8868\u5143\u7d20\u6709\u9ed8\u8ba4\u7684padding\u503c\uff0c\u6240\u4ee5\u6211\u8ba4\u4e3a\u9ad8\u6548\u7684\u5199\u6cd5\u5e94\u8be5\u662f\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>\nbody,p,h1,h2,h3,h4,h5,h6{margin:0;}\nul,ol{list-type:none; margin:0; padding:0;}<\/pre>\n<\/div>\n<\/li>\n<li>\n<pre>span{<del datetime=\"2010-02-04T23:43:40+00:00\">display:inline;<\/del> float:left; margin-left:3px;}<\/pre>\n<p>\u8fd9\u4e5f\u662f\u5e38\u51fa\u73b0\u7684\u3002\u6211\u60f3\u51fa\u73b0\u8fd9\u79cd\u60c5\u51b5\u7684\u539f\u56e0\u53ef\u80fd\u4e0eIE6\u7684\u6d6e\u52a8\u53cc\u8fb9\u8dddbug\u6709\u5173\uff0c\u6211\u4eec\u53ef\u4ee5\u7528\u8bbe\u7f6e<code>display:inline<\/code>\u7684\u65b9\u6cd5\u4fee\u590dIE6\u7684\u8fd9\u4e2abug\uff0c\u4f46\u662f\uff0c\u5982\u679c\u5bf9\u8fd9\u4e2abug\u7406\u89e3\u4e0d\u591f\uff0c\u5bf9CSS\u7684\u7406\u89e3\u4e0d\u8db3\uff0c\u5c31\u4f1a\u51fa\u73b0\u6ee5\u7528\u7684\u60c5\u51b5\u3002\u4e0a\u9762\u662f\u6ee5\u7528\u7684\u60c5\u51b5\u4e4b\u4e00\uff0c\u5bf9\u4e8e<code>span<\/code>\/<code>a<\/code>\/<code>em<\/code>\/<code>cite<\/code>\/<code>i<\/code>\/<code>b<\/code>\/<code>strong<\/code>\u7b49\u884c\u5185\u5143\u7d20\u9ed8\u8ba4\u5c31\u662f<code>display:inline<\/code>\u7684\uff0c\u6240\u4ee5\u7ed9\u5176\u8bbe\u7f6e<code>display:inline<\/code>\u5c5e\u6027\u662f\u591a\u6b64\u4e00\u4e3e\u3002<\/p>\n<p>\u7c7b\u4f3c\u7684\u60c5\u51b5\u8fd8\u6709\u5bf9\u672c\u8eab\u5c31\u662f<code>block<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u8bbe\u7f6e<code>display:block<\/code>\u5c5e\u6027\uff0c\u4f8b\u5982\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>li{<del datetime=\"2010-02-04T18:46:51+00:00\">display:block;<\/del> padding:4px 0;}<\/pre>\n<\/div>\n<p>\u4e0a\u9762\u7684\u60c5\u51b5\u5c61\u89c1\u4e0d\u9c9c\uff0c\u751a\u81f3\u5728\u6bd4\u8f83\u4f18\u79c0\u7684\u7f51\u7ad9\u4e0a\u4e5f\u4f1a\u6709\u8fd9\u7c7b\u4f4e\u7ea7\u7684\u6837\u5f0f\u95ee\u9898\u3002<\/li>\n<li>\u5176\u4ed6\u4e00\u4e9b\u60c5\u51b5\uff1a\n<div class=\"zxx_code\">\n<pre>div{<del datetime=\"2010-02-04T18:46:51+00:00\">margin:auto;<\/del>}<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>textarea{<del datetime=\"2010-02-04T18:46:51+00:00\">overflow:auto;<\/del>}<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>img,input,button{<del datetime=\"2010-02-04T18:46:51+00:00\">vertical-align:baseline;<\/del>}<\/pre>\n<\/div>\n<div class=\"zxx_code\">\n<pre>div{<del datetime=\"2010-02-04T18:46:51+00:00\">background-position:0 0;<\/del>}<\/pre>\n<\/div>\n<\/li>\n<\/ol>\n<h4>2\u3001\u6ca1\u6709\u5fc5\u8981\u51fa\u73b0\u7684\u6837\u5f0f<\/h4>\n<p>\u6700\u5e38\u89c1\u7684\u5c31\u662f<code>clear:both<\/code>\u7684\u4f7f\u7528\u3002<br \/>\n\u5982\u679c\u524d\u540e\u6ca1\u6709\u6d6e\u52a8\u5143\u7d20\u5e72\u6270\uff0c\u4f7f\u7528<code>clear:both<\/code>\u662f\u6ca1\u6709\u9053\u7406\u7684\u3002<br \/>\n\u6bd4\u5982\u8bf4\u65b0\u6d6a\u65b0\u7248\u535a\u5ba2\u4e2a\u4eba\u535a\u5ba2\u7684\u9996\u9875\uff0c<code>clear:both<\/code>\u5c5e\u6027\u53ef\u4ee5\u8bf4\u662f\u6ee5\u7528\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"clear:both\u7684\u6ee5\u7528\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_062211.png\" title=\"clear:both\u7684\u6ee5\u7528\" class=\"alignnone\" width=\"382\" height=\"123\" \/><\/p>\n<p>\u5728\u535a\u5ba2\u5217\u8868\u4e3b\u4f53\u5904\u57fa\u672c\u4e0a\u6bcf\u4e2a<code>div<\/code>\u6807\u7b7e\u90fd\u4f7f\u7528\u4e86<code>clear:both<\/code>\u5c5e\u6027\uff0c\u800c\u8fd9\u91cc\u6240\u6709\u7684<code>clear:both<\/code>\u5c5e\u6027\u90fd\u662f\u53ef\u4ee5\u53bb\u9664\u7684\u3002<\/p>\n<p><code>clear:both<\/code>\u7684\u591a\u4f59\u4f7f\u7528\u53ef\u4ee5\u8bf4\u662f\u76f8\u5f53\u666e\u904d\u4f7f\u7528\u7684\u60c5\u51b5\u3002\u50cf\u662f\u5f00\u5fc3\u7f51\u5e95\u90e8\u7f51\u7ad9\u4fe1\u606f\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\u5f00\u5fc3\u7f51clear:both\u793a\u4f8b \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_063008.png\" title=\"\u5f00\u5fc3\u7f51clear:both\u793a\u4f8b \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" class=\"alignnone\" width=\"533\" height=\"238\" \/><\/p>\n<p>\u8fd9\u91cc\u5c31\u4e0d\u591a\u4e3e\u4f8b\u4e86\uff0c\u53cd\u6b63\u8bb0\u4f4f\uff0c\u8981\u662f\u524d\u540e\u6ca1\u6709\u76f4\u63a5\u7684\u6d6e\u52a8\u5143\u7d20\uff0c\u4f7f\u7528<code>clear:both<\/code>\u5c31\u662f\u591a\u4f59\u7684\u3002<\/p>\n<h4>3\u3001\u4e0d\u8d77\u4f5c\u7528\u7684\u5355\u6837\u5f0f<\/h4>\n<p>\u6709\u4e9bCSS\u6837\u5f0f\u53ea\u9488\u5bf9\u7279\u5b9a\u663e\u793a\u6c34\u5e73\u7684\u6807\u7b7e\u8d77\u4f5c\u7528\u3002<\/p>\n<ol>\n<li><strong>inline\u6c34\u5e73<\/strong><br \/>\n<code>inline<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u5bf9\u5f88\u591aCSS\u6837\u5f0f\u90fd\u4e0d\u8d77\u53cd\u5e94\uff0c\u4f8b\u5982<code>height<\/code>\/<code>width<\/code>, <code>clear<\/code>, <code>margin-top<\/code>\/<code>margin-bottom<\/code>, <code>overflow<\/code>\u7b49\u3002\u4e3e\u4e2a\u5b9e\u4f8b\u5427\uff0c\u62ff<code>overflow:hidden<\/code>\u5c5e\u6027\u4e3e\u4f8b\uff0c\u5bf9\u4e8e<code>inline<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u800c\u8a00\uff0c\u8bbe\u7f6e<code>overflow:hidden<\/code>\u5c5e\u6027\u662f\u6ca1\u6709\u4f5c\u7528\u7684\u3002\u4f8b\u5982\u4e0b\u9762\u7684\u6d4b\u8bd5\u4ee3\u7801\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>\n&lt;span style=\"overflow:hidden;\">\n    &lt;img src=\"mm1.jpg\" style=\"margin-left:-5px;\" \/>\n&lt;span><\/pre>\n<\/div>\n<p>\u5bf9\u6bd4\u4e8e\uff1a<\/p>\n<div class=\"zxx_code\">\n<pre>\n&lt;span style=\"display:inline-block; overflow:hidden;\">\n    &lt;img src=\"mm1.jpg\" style=\"margin-left:-5px;\" \/>\n&lt;span><\/pre>\n<\/div>\n<p>\u5bf9\u6bd4\u56fe\u5982\u4e0b\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201801\/2018-01-01_151315.png\" width=\"392\" height=\"258\" alt=\"inline\u5143\u7d20\u4e0eoverflow:hidden\" class=\"alignnone\" \/><\/p>\n<p>\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a target=\"_blank\" class=\"a_link\" href=\"http:\/\/www.zhangxinxu.com\/study\/201002\/inline-overflow-test-demo.html\">inline\u5143\u7d20\u4e0eoverflow\u5c5e\u6027demo<\/a><\/li>\n<li><strong>block\u6c34\u5e73<\/strong><br \/>\n<code>block<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u5bf9<code>vertical-align<\/code>\u5c5e\u6027\u6ca1\u6709\u4f5c\u7528\u3002<\/li>\n<li><strong>\u7ec4\u5408\u8d77\u4f5c\u7528<\/strong><br \/>\n\u6709\u4e9b\u6837\u5f0f\u9700\u8981\u548c\u5176\u4ed6\u4e00\u4e9b\u7279\u5b9a\u7684CSS\u5c5e\u6027\u4e00\u8d77\u4f7f\u7528\u624d\u6709\u4f5c\u7528\u3002\u5e38\u89c1\u7684\u5c31\u662f<code>z-index<\/code>\u4e0e<code>position<\/code>\u5c5e\u6027\u7684\u7ec4\u5408\u4f7f\u7528\uff0c<code>left<\/code>\/<code>top<\/code>\/<code>bottom<\/code>\/<code>right<\/code>\u4e0e<code>position<\/code>\u5c5e\u6027\u7684\u7ec4\u5408\u4f7f\u7528\u3002<\/li>\n<\/ol>\n<p><strong>4\u3001\u7ec4\u5408\u6837\u5f0f\u4e2d\u591a\u4f59\u7684CSS\u4ee3\u7801<\/strong><br \/>\n\u8fd9\u79cd\u60c5\u51b5\u5c31\u591a\u4e86\uff0c\u5b9e\u9645\u60c5\u51b5\u4e0b\uff0c\u7275\u626f\u5230\u7ee7\u627f\uff0c\u547d\u540d\u51b2\u7a81\uff0c\u4e66\u5199\u7b49\uff0c\u8fd9\u91cc\u4ec5\u4ec5\u4e3e\u4e00\u4e9b\u5e38\u89c1\u7684\u591a\u4f59\u6837\u5f0f\u7684\u4f8b\u5b50\uff0c\u76f8\u4fe1\u60a8\u4f1a\u5728\u5176\u4e2d\u627e\u5230\u60a8\u81ea\u5df1\u7684\u4e00\u4e9b\u9519\u8bef\u7684\u3002<\/p>\n<ol>\n<li>\n<pre>a{<del datetime=\"2010-02-04T18:46:51+00:00\">display:block;<\/del> float:left; margin-top:2px;}<\/pre>\n<p>\u8fd9\u53ef\u4ee5\u8bf4\u662f\u6700\u5e38\u89c1\u7684\u542b\u6709\u591a\u4f59\u6837\u5f0f\u7684\u4f8b\u5b50\u4e86\uff0c\u5f00\u5fc3\u7f51\u4e2a\u4eba\u9996\u9875\u53ef\u8c13\u968f\u5904\u53ef\u89c1\uff0c\u89c1\u4e0b\u56fe\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"block+float \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_070853.png\" title=\"block+float \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" class=\"alignnone\" width=\"499\" height=\"292\" \/><\/p>\n<p>\u8fd9\u91cc\u7684<code>display<\/code>\u5c5e\u6027\u5b8c\u5168\u6ca1\u6709\u5fc5\u8981\uff0c\u5bf9\u4e8e<code>a<\/code>\u6216\u662f<code>span<\/code>\u6807\u7b7e\u800c\u8a00\uff0c\u6ca1\u6709\u4efb\u4f55\u7406\u7531\u4f7f\u7528<code>display<\/code>+<code>float<\/code>\u7684\u7ec4\u5408\uff0c\u56e0\u4e3a<code>float<\/code>\u6240\u4ea7\u751f\u7684\u201c\u5305\u88f9\u201d\u4f5c\u7528\u5df2\u7ecf\u8ba9\u5143\u7d20\u5982\u540c\u4e00\u4e2a<code>inline-block<\/code>\u6c34\u5e73\u7684\u5143\u7d20\uff0c\u8fd9\u79cd\u4f5c\u7528\u5927\u4e8e\u76f4\u63a5\u7684<code>display<\/code>\u8bbe\u7f6e\u3002<\/p>\n<p>\u4ec5\u4ec5\u4e00\u79cd\u60c5\u51b5\u4e0b\u6709\u5fc5\u8981\u4f7f\u7528<code>display<\/code>+<code>float<\/code>\u7684\u7ec4\u5408\uff0c\u5c31\u662f<code>block<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u5728IE6\u4e0b\u7684\u53cc\u8fb9\u8dddbug\u95ee\u9898\uff0c\u8fd9\u79cd\u60c5\u51b5\u7684\u552f\u4e00\u5199\u6cd5\u5c31\u662f<code>display:inline; float:left; margin-left:3px;<\/code>\u4e00\u5b9a\u8981\u6709\u4e0e<code>float<\/code>\u6d6e\u52a8\u540c\u65b9\u5411\u7684<code>margin<\/code>\u503c\uff0c\u5426\u5219<code>display:inline<\/code>\u662f\u591a\u4f59\u7684\uff0c\u53ef\u4ee5\u76f4\u63a5\u53bb\u6389\u3002<\/li>\n<li>\n<pre>div{<del datetime=\"2010-02-04T18:46:51+00:00\">height:25px;<\/del> line-height:25px;}<\/pre>\n<p>\u8fd9\u53c8\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u5e73\u65f6\u4e0d\u6ce8\u610f\u7684\u53ef\u4ee5\u7cbe\u7b80\u7684CSS\u4ee3\u7801\uff0c\u8fd9\u6bb5\u4ee3\u7801\u9ad8\u5ea6\u4e0e<code>line-height<\/code>\u503c\u4e00\u81f4\uff0c\u901a\u5e38\u4f5c\u7528\u662f\u5b9e\u73b0\u5355\u884c\u6587\u5b57\u7684\u5782\u76f4\u5c45\u4e2d\u663e\u793a\u3002\u4f46\u662f\u5b9e\u9645\u4e0a\uff0c\u5f88\u591a\u60c5\u51b5\u4e0b\uff0c\u8fd9\u91cc\u7684<code>height<\/code>\u662f\u4e2a\u591a\u4f59\u7684\u503c\uff0c\u5c24\u5176\u5728\u6a21\u5757\u6807\u9898\u5904\u3002\u5bf9\u4e8e\u5355\u884c\u6587\u5b57\u800c\u8a00\uff0c\u60a8\u8bbe\u7f6e<code>line-height<\/code>\u591a\u5927\uff0c\u5176\u5b9e\u9645\u5360\u636e\u7684\u5782\u76f4\u9ad8\u5ea6\u5c31\u662f\u591a\u9ad8\uff0c\u6ca1\u6709\u4efb\u4f55\u7684\u517c\u5bb9\u6027\u95ee\u9898\uff0c\u53ef\u4ee5\u653e\u5fc3\u4f7f\u7528\u3002<\/p>\n<p>\u4f46\u662f\uff0c\u6709\u65f6\u5019\u8fd9\u91cc\u7684<code>height<\/code>\u503c\u662f\u6709\u5fc5\u8981\u7684\uff0c\u4ec0\u4e48\u65f6\u5019\u5462\uff1f\u5c31\u662fIE6\/7\u6e05\u9664\u6d6e\u52a8\u5f71\u54cd\u7684\u65f6\u5019\uff0cIE6\/7\u4e0b\u8bbe\u7f6e<code>height<\/code>\u503c\u53ef\u4ee5\u8ba9\u5143\u7d20haslayout\u4ece\u800c\u6e05\u9664\u6d6e\u52a8\u7684\u5f71\u54cd\uff0c\u800c<code>line-height<\/code>\u65e0\u6b64\u4f5c\u7528\uff0c\u8fd8\u6709\u5c31\u662f\u5176\u4ed6\u4e00\u4e9b\u9700\u8981layout\u7684\u60c5\u51b5\u3002<\/li>\n<li>\n<pre>span{display:block; <del datetime=\"2010-02-04T18:46:51+00:00\">width:100%;<\/del>}\ndiv{<del datetime=\"2010-02-05T00:54:55+00:00\">width:100%;<\/del>}\nbody{<del datetime=\"2010-02-05T00:54:55+00:00\">width:100%;<\/del>}<\/pre>\n<p>\u8fd9\u4e5f\u662f\u5e38\u89c1\u7684\u4f7f\u7528\u591a\u4f59CSS\u6837\u5f0f\u7684\u60c5\u51b5\uff0c<code>width:100%<\/code>\u3002\u5728\u4e00\u822c\u60c5\u51b5\u4e0b\uff0c\u5bf9\u4e8e<code>block<\/code>\u5c5e\u6027\u7684\u5143\u7d20\uff0c<code>width:100%<\/code>\u8fd9\u4e2a\u5c5e\u6027\u7edd\u5bf9\u662f\u591a\u4f59\u7684\u3002\u9ed8\u8ba4\u7684\uff0c<code>block<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u5c31\u662f\u5bbd\u5ea6\u76f8\u5bf9\u4e8e\u7236\u6807\u7b7e<code>100%<\/code>\u663e\u793a\u7684\u3002<\/p>\n<p>\u5f53\u7136\uff0c\u4e0d\u4f7f\u7528<code>100%<\/code>\u7684\u60c5\u51b5\u4e0d\u662f\u7edd\u5bf9\u7684\uff0c\u4e0b\u9762\u8fd9\u4e2a\u7ec4\u5408\u53ef\u80fd\u4f7f\u7528<code>width:100%<\/code>\u662f\u6709\u5fc5\u8981\u7684\u3002<\/p>\n<pre>div{width:100%; overflow:hidden;}<\/pre>\n<p>\u5728IE6\/7\uff08\u6ca1\u6709IE8\uff09\u4e0b\uff0c\u5bf9\u4e8eblock\u6c34\u5e73\u7684\u5143\u7d20\uff0c\u6211\u4eec\u53ef\u4ee5\u4f7f\u7528<code>width:100%<\/code>\u6e05\u9664\u6d6e\u52a8\u9020\u6210\u7684\u5f71\u54cd\uff0c\u539f\u56e0\u4e0e\u4e0a\u4f8b\u4e00\u6837\uff0chaslayout\uff0c\u9664\u4e86\u8fd9\u79cd\u60c5\u51b5\uff0c\u7eaf\u7cb9\u7684<code>{width:100%;}<\/code>\u6837\u5f0f\uff08\u65e0<code>float<\/code>\u6216\u662f<code>position:absolute<\/code>\u4e4b\u7c7b\u7684\u6837\u5f0f\uff09\u662f\u4e0d\u53ef\u80fd\u51fa\u73b0\u7684\u3002\u6240\u4ee5\uff0c\u5982\u679c\u60a8\u7684CSS\u4ee3\u7801\u4e2d\u51fa\u73b0\u4e0a\u8ff0\u60c5\u51b5\uff0c\u68c0\u67e5\u4e0b\u60a8\u7684<code>width:100%<\/code>\u662f\u4e0d\u662f\u591a\u4f59\u7684\u3002\uff08\u4e0b\u56fe\u4e3a\u641c\u72d0\u767d\u793e\u4f1a\u52a8\u6001\u5217\u8868\u4e2d\u591a\u4f59width:100%\u60c5\u51b5\uff09<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\u641c\u72d0\u767d\u793e\u4f1a\u65e0\u6548width:100%\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_073557.png\" class=\"alignnone\" width=\"457\" height=\"222\" \/><\/li>\n<li>\n<pre>div{float:left\/display:inline; <del datetime=\"2010-02-04T23:43:40+00:00\">vertical-align:middle;<\/del>}<\/pre>\n<p>\u8bbe\u7f6e\u65e0\u7528\u7684<code>vertical-align<\/code>\u5c5e\u6027\u4e5f\u662f\u5e38\u89c1\u7684\u3002\u5bf9\u4e8e<code>block<\/code>\/<code>inline<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u6216\u662f\u8bbe\u7f6e\u4e86\u6d6e\u52a8\u5c5e\u6027\u6216\u662f<code>absolute<\/code>\u7edd\u5bf9\u5b9a\u4f4d\u7684\u5143\u7d20\uff0c\u5176\u90fd\u4e0d\u652f\u6301<code>vertical-align<\/code>\u5c5e\u6027\u3002\u6240\u4ee5\u8fd9\u4e9b\u5c5e\u6027\u4e0e<code>vertical-align<\/code>\u540c\u65f6\u51fa\u73b0\u65f6\uff0c<code>vertical-align<\/code>\u5c5e\u6027\u4e0d\u8d77\u4efb\u4f55\u4f5c\u7528\u662f\u591a\u4f59\u7684\u3002<\/p>\n<p>\u4f8b\u5982\u4eba\u4eba\u7f51\u53f3\u4fa7\u7684\u5782\u76f4\u83dc\u5355<code>block<\/code>\u6c34\u5e73\u7684<code>li<\/code>\u5143\u7d20\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"\u4eba\u4eba\u7f51\u65e0\u7528\u7684vertical-align\u5c5e\u6027 \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_080540.png\" title=\"\u4eba\u4eba\u7f51\u65e0\u7528\u7684vertical-align\u5c5e\u6027 \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" class=\"alignnone\" width=\"434\" height=\"244\" \/><\/p>\n<p>\u6216\u662f\u6dd8\u5b9d\u65b0\u7248\u9996\u9875\u5de6\u4e0a\u4fa7\u7684\u5782\u76f4\u5217\u8868\uff1a<br \/>\n<img loading=\"lazy\" decoding=\"async\" alt=\"\u6dd8\u5b9d\u65b0\u7248\u9996\u9875\u65e0\u6548\u7684vertical-align\u5c5e\u6027 \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_081043.png\" title=\"\u6dd8\u5b9d\u65b0\u7248\u9996\u9875\u65e0\u6548\u7684vertical-align\u5c5e\u6027 \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" class=\"alignnone\" width=\"530\" height=\"229\" \/><\/p>\n<p>\u6211\u662f\u5b9e\u5728\u60f3\u4e0d\u51fa\u8fd9\u91cc\u8981\u4f7f\u7528<code>vertical-align<\/code>\u5c5e\u6027\u7684\u7406\u7531\u3002<\/li>\n<li>\n<pre>div{position:absolute; left:0; top:0; <del datetime=\"2010-02-04T23:43:40+00:00\">display:inline;<\/del> <del datetime=\"2010-02-04T23:43:40+00:00\">float:left;<\/del> <del datetime=\"2010-02-04T23:43:40+00:00\">margin-left:10px;<\/del>}<\/pre>\n<p>\u8bbe\u7f6e\u4e86\u7edd\u5bf9\u5b9a\u4f4d\u5c5e\u6027\u7684\u5143\u7d20\u76f8\u5bf9\u7279\u6b8a\u4e9b\uff0c\u5176\u4e0d\u652f\u6301\u7684CSS\u6837\u5f0f\u53ef\u5c31\u591a\u4e86\uff0c\u9996\u5148\u5bf9\u4e8e<code>display<\/code>\u5c5e\u6027\uff0c\u5b8c\u5168\u6ca1\u6709\u5fc5\u8981\uff0c\u65e0\u8bba\u662f<code>block<\/code>\/<code>inline-block<\/code>\/<code>inline<\/code>\u90fd\u662f\u5982\u6b64\uff0c\u9664\u4e86\u73b0\u5b9e\u9690\u85cf\u5916\uff0c\u6ca1\u6709\u4efb\u4f55\u7ec4\u5408\u4f7f\u7528\u7684\u7406\u7531\u3002\u8fd8\u6709\u5176\u4ed6\u5f88\u591a\u5c5e\u6027\u90fd\u4e0d\u652f\u6301\uff0c\u4f8b\u5982<code>clear<\/code>\uff0c<code>vertical-align<\/code>\u7b49\u3002<\/li>\n<li>\n<pre>div{height:20px\/width:200px; <del datetime=\"2010-02-04T23:43:40+00:00\">zoom:1;<\/del> overflow:hidden;}<\/pre>\n<p>\u6211\u4eec\u53ef\u80fd\u4f1a\u4f7f\u7528zoom\u6e05\u9664IE6\/7\uff08\u5bf9IE8\u65e0\u6548\uff09\u6d4f\u89c8\u5668\u4e0b\u6d6e\u52a8\u9020\u6210\u7684\u5f71\u54cd\u3002\u4f46\u662f\u5bf9\u4e8eIE6\/7\u800c\u8a00\uff0c\u5982\u679c\u60a8\u5df2\u7ecf\u8bbe\u7f6e\u4e86\u9ad8\u5ea6\u503c\u6216\u662f\u5bbd\u5ea6\u503c\uff0c\u90a3\u4e48<code>zoom:1<\/code>\u5b8c\u5168\u5c31\u662f\u591a\u4f59\u7684\uff0c\u5728IE6\/7\u4e0b\u542b\u6709\u5b9a\u503c\u7684<code>height<\/code>\u6216\u662f<code>width<\/code>\u4e0ezoom:1\u8d77\u5230\u4e86\u540c\u6837\u7684\u4e00\u4e2a\u4f5c\u7528\uff0c\u5c31\u662f\u4f7f\u5143\u7d20haslayout\uff0c\u53ef\u7528\u6765\u6e05\u9664\u6d6e\u52a8\u4ea7\u751f\u7684\u5f71\u54cd\uff0c\u6240\u4ee5\uff0c<code>width<\/code>\/<code>height<\/code>\u4e0e<code>zoom:1<\/code>\u540c\u65f6\u51fa\u73b0\u4e5f\u662f\u6ca1\u6709\u4efb\u4f55\u7406\u7531\u7684\u3002<\/li>\n<li>\u5176\u5b83\u60c5\u51b5\n<pre>a{display:inline-block; <del datetime=\"2010-02-04T23:43:40+00:00\">*display:inline;<\/del> <del datetime=\"2010-02-04T23:43:40+00:00\">*zoom:1;<\/del>}<\/pre>\n<p>\u8fd9\u662f\u8bbe\u7f6e\u5143\u7d20\u7684<code>inline-block<\/code>\u5c5e\u6027\uff0c\u4f46\u662f\u5bf9\u4e8e<code>inline<\/code>\u884c\u5185\u5143\u7d20\u6765\u8bf4\uff0c\u540e\u9762\u7684\u4e24\u4e2a\u6837\u5f0f\u5c31\u662f\u591a\u4f59\u7684\uff0c\u56e0\u4e3a<code>display:inline-block<\/code>\u53ef\u4ee5\u8ba9<code>inline<\/code>\u6c34\u5e73\u7684\u5143\u7d20\u8868\u73b0\u7684\u5c31\u5982\u540c\u771f\u6b63\u7684<code>inline-block<\/code>\u6c34\u5e73\u4e00\u6837\u3002<br \/>\n\u6240\u4ee5\uff0c\u4e0b\u56fe\u4eba\u4eba\u7f51\u6837\u5f0f\u4ee3\u7801\u4e2d\u6807\u6ce8\u7684\u4ee3\u7801\u5c31\u662f\u591a\u4f59\u7684\u3002\u5982\u679c\u662f<code>div<\/code>\uff0c\u5219\u9700\u8981\u4e0a\u9762\u5b8c\u6574\u4ee3\u7801\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\u4eba\u4eba\u7f51\u65e0\u7528\u4ee3\u7801 \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" src=\"http:\/\/image.zhangxinxu.com\/image\/blog\/201002\/2010-02-05_083417.png\" title=\"\u4eba\u4eba\u7f51\u65e0\u7528\u4ee3\u7801 \u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b\" class=\"alignnone\" width=\"533\" height=\"250\" \/><\/li>\n<\/ol>\n<p>\u597d\u5427\uff0c\u5c31\u5148\u6574\u7406\u8fd9\u4e48\u591a\uff0c\u4ee5\u540e\u8981\u662f\u6709\u65b0\u53d1\u73b0\u518d\u6765\u8865\u5145\u3002\u4e5f\u6b22\u8fce\u60a8\u6765\u8865\u5145\u3002<\/p>\n<h3>\u4e09\u3001\u6700\u540e\u7684\u7b80\u77ed\u5520\u53e8<\/h3>\n<p>\u4f7fCSS\u4ee3\u7801\u8db3\u591f\u7cbe\u7b80\u7684\u65b9\u6cd5\u5c31\u662f\u5bf9\u6bcf\u4e2aCSS\u6837\u5f0f\u90fd\u8981\u975e\u5e38\u7684\u719f\u6089\u4e86\u89e3\uff0c\u5c31\u50cf\u4e86\u89e3\u81ea\u5df1\u7684\u5b69\u5b50\u90a3\u6837\u53bb\u4e86\u89e3\u5b83\uff0c\u8fd9\u6837\u5b50\uff0c\u5199\u51fa\u65e0\u7528\u6837\u5f0f\u7684\u51e0\u7387\u5c31\u4f1a\u9010\u6e10\u51cf\u5c0f\u5566\u3002<\/p>\n<p>\u5c31\u8bf4\u8fd9\u4e9b\u5427\u3002<\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u8f6c\u8f7d\u8bf7\u6ce8\u660e\u6765\u81ea<a href=\"http:\/\/www.zhangxinxu.com\/\">\u5f20\u946b\u65ed-\u946b\u7a7a\u95f4-\u946b\u751f\u6d3b<\/a>[<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=629\">http:\/\/www.zhangxinxu.com\/wordpress\/?p=629<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6211\u57fa\u672c\u4e0a\u53ef\u4ee5\u5728\u56fd\u5185\u4efb\u610f\u7684\u7f51\u7ad9\u4e0a\u627e\u5230\u5197\u4f59\u7684CSS\u4ee3\u7801\uff0c\u53ef\u89c1CSS\u4ee3\u7801\u7684\u5197\u4f59\u662f\u975e\u5e38\u666e\u904d\u7684\uff0c\u672c\u6587\u5c31\u5217\u4e3e\u4e86\u4e00\u4e9b\u5e38\u89c1\u7684\u4f7f\u7528\u65e0\u6548CSS\u4ee3\u7801\u7684\u60c5\u51b5\uff0c\u60a8\u53ef\u4ee5\u5bf9\u7167\u5206\u6790\u770b\u770b\u60a8\u7684\u4ee3\u7801\u662f\u5426\u4e5f\u5b58\u5728\u7c7b\u4f3c\u60c5\u51b5\u3002<br \/>\n\u63d0\u4f9b\u8be6\u5c3d\u7684\u63d2\u56fe\uff0c\u63d0\u4f9b\u76f8\u5e94\u7684demo\uff0c\u5e0c\u671b\u80fd\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\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,1271,315,40,151,331,330],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/629"}],"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=629"}],"version-history":[{"count":0,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/629\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}