{"id":325,"date":"2009-04-17T13:44:00","date_gmt":"2009-04-17T05:44:00","guid":{"rendered":""},"modified":"2013-11-29T11:45:46","modified_gmt":"2013-11-29T03:45:46","slug":"%e5%b8%b8%e7%94%a8css%e7%bc%a9%e5%86%99%e6%80%bb%e7%bb%93","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/325.html","title":{"rendered":"\u5e38\u7528CSS\u7f29\u5199\u603b\u7ed3"},"content":{"rendered":"<p>\u4f7f\u7528\u7f29\u5199\u53ef\u4ee5\u5e2e\u52a9\u51cf\u5c11\u4f60CSS\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u66f4\u52a0\u5bb9\u6613\u9605\u8bfb\u3002css\u7f29\u5199\u7684\u4e3b\u8981\u89c4\u5219\u5982\u4e0b\uff1a<\/p>\n<p>\u989c\u8272<\/p>\n<p>16\u8fdb\u5236\u7684\u8272\u5f69\u503c\uff0c\u5982\u679c\u6bcf\u4e24\u4f4d\u7684\u503c\u76f8\u540c\uff0c\u53ef\u4ee5\u7f29\u5199\u4e00\u534a\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>#000000\u53ef\u4ee5\u7f29\u5199\u4e3a#000;#336699\u53ef\u4ee5\u7f29\u5199\u4e3a#369;<\/p>\n<p>\u76d2\u5c3a\u5bf8<\/p>\n<p>\u901a\u5e38\u6709\u4e0b\u9762\u56db\u79cd\u4e66\u5199\u65b9\u6cd5:<\/p>\n<p>property:value1; \u8868\u793a\u6240\u6709\u8fb9\u90fd\u662f\u4e00\u4e2a\u503cvalue1;<br \/>\nproperty:value1 value2; \u8868\u793atop\u548cbottom\u7684\u503c\u662fvalue1,right\u548cleft\u7684\u503c\u662fvalue2<br \/>\nproperty:value1 value2 value3; \u8868\u793atop\u7684\u503c\u662fvalue1\uff0cright\u548cleft\u7684\u503c\u662fvalue2\uff0cbottom\u7684\u503c\u662fvalue3<br \/>\nproperty:value1 value2 value3 value4; \u56db\u4e2a\u503c\u4f9d\u6b21\u8868\u793atop,right,bottom,left<br \/>\n\u65b9\u4fbf\u7684\u8bb0\u5fc6\u65b9\u6cd5\u662f\u987a\u65f6\u9488\uff0c\u4e0a\u53f3\u4e0b\u5de6\u3002\u5177\u4f53\u5e94\u7528\u5728margin\u548cpadding\u7684\u4f8b\u5b50\u5982\u4e0b\uff1a<\/p>\n<p>margin:1em 0 2em 0.5em;<\/p>\n<p>\u8fb9\u6846(border)<\/p>\n<p>\u8fb9\u6846\u7684\u5c5e\u6027\u5982\u4e0b\uff1a<\/p>\n<p>border-width:1px;<br \/>\nborder-style:solid;<br \/>\nborder-color:#000;<br \/>\n\u53ef\u4ee5\u7f29\u5199\u4e3a\u4e00\u53e5\uff1aborder:1px solid #000;<\/p>\n<p>\u8bed\u6cd5\u662fborder:width style color;<\/p>\n<p>\u80cc\u666f(Backgrounds)<\/p>\n<p>\u80cc\u666f\u7684\u5c5e\u6027\u5982\u4e0b\uff1a<\/p>\n<p>background-color:#f00;<br \/>\nbackground-image:url(background.gif);<br \/>\nbackground-repeat:no-repeat;<br \/>\nbackground-attachment:fixed;<br \/>\nbackground-position:0 0;<br \/>\n\u53ef\u4ee5\u7f29\u5199\u4e3a\u4e00\u53e5\uff1abackground:#f00 url(background.gif) no-repeat fixed 0 0;<\/p>\n<p>\u8bed\u6cd5\u662fbackground:color image repeat attachment position;<\/p>\n<p>\u4f60\u53ef\u4ee5\u7701\u7565\u5176\u4e2d\u4e00\u4e2a\u6216\u591a\u4e2a\u5c5e\u6027\u503c\uff0c\u5982\u679c\u7701\u7565\uff0c\u8be5\u5c5e\u6027\u503c\u5c06\u7528\u6d4f\u89c8\u5668\u9ed8\u8ba4\u503c\uff0c\u9ed8\u8ba4\u503c\u4e3a\uff1a<\/p>\n<p>color: transparent<br \/>\nimage: none<br \/>\nrepeat: repeat<br \/>\nattachment: scroll<br \/>\nposition: 0% 0%<br \/>\n\u5b57\u4f53(fonts)<\/p>\n<p>\u5b57\u4f53\u7684\u5c5e\u6027\u5982\u4e0b\uff1a<\/p>\n<p>font-style:italic;<br \/>\nfont-variant:small-caps;<br \/>\nfont-weight:bold;<br \/>\nfont-size:1em;<br \/>\nline-height:140%;<br \/>\nfont-family:&#8221;Lucida Grande&#8221;,sans-serif;<br \/>\n\u53ef\u4ee5\u7f29\u5199\u4e3a\u4e00\u53e5\uff1afont:italic small-caps bold 1em\/140% &#8220;Lucida Grande&#8221;,sans-serif;<\/p>\n<p>\u6ce8\u610f\uff0c\u5982\u679c\u4f60\u7f29\u5199\u5b57\u4f53\u5b9a\u4e49\uff0c\u81f3\u5c11\u8981\u5b9a\u4e49font-size\u548cfont-family\u4e24\u4e2a\u503c\u3002<\/p>\n<p>\u5217\u8868(lists)<\/p>\n<p>\u53d6\u6d88\u9ed8\u8ba4\u7684\u5706\u70b9\u548c\u5e8f\u53f7\u53ef\u4ee5\u8fd9\u6837\u5199list-style:none;,<\/p>\n<p>list\u7684\u5c5e\u6027\u5982\u4e0b:<\/p>\n<p>list-style-type:square;<br \/>\nlist-style-position:inside;<br \/>\nlist-style-image:url(image.gif);<br \/>\n\u53ef\u4ee5\u7f29\u5199\u4e3a\u4e00\u53e5\uff1alist-style:square inside url(image.gif);<\/p>\n<p>1. css \u5b57\u4f53\u7b80\u5199\u89c4\u5219<\/p>\n<p>\u5f53\u4f7f\u7528css\u5b9a\u4e49\u5b57\u4f53\u65f6\u4f60\u53ef\u80fd\u4f1a\u8fd9\u6837\u505a\uff1a<\/p>\n<p>font-size: 1em;<br \/>\nline-height: 1.5em;<br \/>\nfont-weight: bold;<br \/>\nfont-style: italic;<br \/>\nfont-variant: small-caps;<br \/>\nfont-family: verdana,serif;<\/p>\n<p>\u4e8b\u5b9e\u4e0a\u4f60\u53ef\u4ee5\u7b80\u5199\u8fd9\u4e9b\u5c5e\u6027\uff1a<\/p>\n<p>font: 1em\/1.5em bold italic small-caps verdana,serif<\/p>\n<p>\u73b0\u5728\u597d\u591a\u4e86\u5427\uff0c\u4e0d\u8fc7\u6709\u4e00\u70b9\u8981\u6ce8\u610f\uff1a\u4f7f\u7528\u8fd9\u4e00\u7b80\u5199\u65b9\u5f0f\u4f60\u81f3\u5c11\u8981\u6307\u5b9a font-size \u548c font-family \u5c5e\u6027\uff0c\u5176\u4ed6\u7684\u5c5e\u6027(\u5982 font-weight\uff0cfont-style\uff0cfont-varient)\u5982\u672a\u6307\u5b9a\u5c06\u81ea\u52a8\u4f7f\u7528\u9ed8\u8ba4\u503c\u3002<\/p>\n<p>2. \u540c\u65f6\u4f7f\u7528\u4e24\u4e2aclass<\/p>\n<p>\u901a\u5e38\u6211\u4eec\u53ea\u4e3a\u5c5e\u6027\u6307\u5b9a\u4e00\u4e2aclass\uff0c\u4f46\u8fd9\u5e76\u4e0d\u7b49\u4e8e\u4f60\u53ea\u80fd\u6307\u5b9a\u4e00\u4e2a\uff0c\u5b9e\u9645\u4e0a\uff0c\u4f60\u60f3\u6307\u5b9a\u591a\u5c11\u5c31\u53ef\u4ee5\u6307\u5b9a\u591a\u5c11\uff0c\u4f8b\u5982\uff1a<\/p>\n<p>&lt;p class=&#8221;text side&#8221;&gt;&#8230;&lt;\/p&gt;<\/p>\n<p>\u901a\u8fc7\u540c\u65f6\u4f7f\u7528\u4e24\u4e2a class(\u4f7f\u7528\u7a7a\u683c\u800c\u4e0d\u662f\u9017\u53f7\u5206\u5272)\uff0c\u8fd9\u4e2a\u6bb5\u843d\u5c06\u540c\u65f6\u5e94\u7528\u4e24\u4e2a class \u4e2d\u5236\u5b9a\u7684\u89c4\u5219\u3002\u5982\u679c\u4e24\u8005\u4e2d\u6709\u4efb\u4f55\u89c4\u5219\u91cd\u53e0\uff0c\u90a3\u4e48\u540e\u4e00\u4e2a\u5c06\u83b7\u5f97\u5b9e\u9645\u7684\u4f18\u5148\u5e94\u7528\u3002<\/p>\n<p>3. css\u4e2d\u8fb9\u6846(border)\u7684\u9ed8\u8ba4\u503c<\/p>\n<p>\u5f53\u7f16\u5199\u4e00\u6761\u8fb9\u6846\u7684\u89c4\u5219\u65f6\uff0c\u4f60\u901a\u5e38\u4f1a\u6307\u5b9a\u989c\u8272\u3001\u5bbd\u5ea6\u4ee5\u53ca\u6837\u5f0f(\u4efb\u4f55\u987a\u5e8f\u5747\u53ef)\u3002\u4f8b\u5982\uff1aborder: 3px solid #000(3\u50cf\u7d20\u5bbd\u7684\u9ed1\u8272\u5b9e\u7ebf\u8fb9\u6846)\uff0c\u5176\u5b9e\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\u552f\u4e00\u9700\u8981\u6307\u5b9a\u7684\u503c\u53ea\u662f\u6837\u5f0f\u3002\u5047\u5982\u4f60\u6307\u5b9a\u6837\u5f0f\u4e3a\u5b9e\u7ebf(solid)\uff0c\u90a3\u4e48\u5176\u4f59\u7684\u503c\u5c06\u4f7f\u7528\u9ed8\u8ba4\u503c\uff1a\u9ed8\u8ba4\u7684\u5bbd\u5ea6\u4e3a\u4e2d\u7b49(\u76f8\u5f53\u4e8e3\u52304\u50cf\u7d20);\u9ed8\u8ba4\u7684\u989c\u8272\u4e3a\u8fb9\u6846\u91cc\u7684\u6587\u5b57\u989c\u8272\u3002\u5982\u679c\u8fd9\u6b63\u662f\u4f60\u60f3\u8981\u7684\u6548\u679c\uff0c\u4f60\u5b8c\u5168\u53ef\u4ee5\u4e0d\u5728css\u91cc\u6307\u5b9a\u3002<\/p>\n<p>4. !important\u4f1a\u88abIE\u5ffd\u7565<\/p>\n<p>\u5728 css \u4e2d\uff0c\u901a\u5e38\u6700\u540e\u6307\u5b9a\u7684\u89c4\u5219\u4f1a\u83b7\u5f97\u4f18\u5148\u6743\u3002\u7136\u800c\u5bf9\u9664\u4e86IE\u4ee5\u5916\u7684\u6d4f\u89c8\u5668\u6765\u8bf4\uff0c\u4efb\u4f55\u540e\u9762\u6807\u6709 !important \u7684\u8bed\u53e5\u5c06\u83b7\u5f97\u7edd\u5bf9\u7684\u4f18\u5148\u6743\uff0c\u4f8b\u5982\uff1amargin-top: 3.5em !important; margin-top: 2em\u3002<\/p>\n<p>\u9664IE\u4ee5\u5916\u6240\u6709\u6d4f\u89c8\u5668\u4e2d\u7684\u9876\u90e8\u8fb9\u754c\u90fd\u662f3.5em\uff0c\u800cIE\u4e3a2em\uff0c\u6709\u65f6\u5019\u8fd9\u4e00\u70b9\u5f88\u6709\u7528\uff0c\u5c24\u5176\u5728\u4f7f\u7528\u76f8\u5bf9\u8fb9\u754c\u503c\u65f6(\u5c31\u50cf\u8fd9\u4e2a\u4f8b\u5b50)\uff0c\u53ef\u4ee5\u663e\u793a\u51faIE\u4e0e\u5176\u4ed6\u6d4f\u89c8\u5668\u7684\u7ec6\u5fae\u5dee\u522b\u3002(\u5f88\u591a\u4eba\u53ef\u80fd\u8fd8\u6ce8\u610f\u5230\u4e86css\u7684\u5b50\u9009\u62e9\u5668\u4e5f\u662f\u4f1a\u88abIE\u5ffd\u7565\u7684)<\/p>\n<p>5. \u56fe\u7247\u66ff\u6362\u7684\u6280\u5de7<\/p>\n<p>\u4f7f\u7528\u6807\u51c6\u7684html\u800c\u4e0d\u662f\u56fe\u7247\u6765\u663e\u793a\u6587\u5b57\u901a\u5e38\u66f4\u4e3a\u660e\u667a\uff0c\u9664\u4e86\u52a0\u5feb\u4e0b\u8f7d\u8fd8\u53ef\u4ee5\u83b7\u5f97\u66f4\u597d\u7684\u53ef\u7528\u6027\u3002\u4f46\u662f\u5982\u679c\u4f60\u51b3\u5fc3\u4f7f\u7528\u8bbf\u95ee\u8005\u7684\u673a\u5668\u4e2d\u53ef\u80fd\u6ca1\u6709\u7684\u5b57\u4f53\u65f6\uff0c\u4f60\u53ea\u80fd\u9009\u62e9\u56fe\u7247\u3002<\/p>\n<p>\u4e3e\u4f8b\u6765\u8bf4\uff0c\u4f60\u60f3\u5728\u6bcf\u4e00\u9875\u7684\u9876\u90e8\u4f7f\u7528\u201cBuy widgets\u201d\u7684\u6807\u9898\uff0c\u4f46\u4f60\u540c\u65f6\u53c8\u5e0c\u671b\u8fd9\u662f\u80fd\u88ab\u641c\u7d22\u5f15\u64ce\u53d1\u73b0\u7684\uff0c\u4e3a\u4e86\u7f8e\u89c2\u4f60\u4f7f\u7528\u4e86\u5c11\u89c1\u7684\u5b57\u4f53\u90a3\u4e48\u4f60\u5c31\u5f97\u7528\u56fe\u7247\u6765\u663e\u793a\u4e86\uff1a<\/p>\n<p>&lt;h1&gt;&lt;img src=&#8221;widget-image.gif&#8221; alt=&#8221;Buy widgets&#8221; \/&gt;&lt;\/h1&gt;<\/p>\n<p>\u8fd9\u6837\u5f53\u7136\u6ca1\u9519\uff0c\u4f46\u662f\u6709\u8bc1\u636e\u663e\u793a\u641c\u7d22\u5f15\u64ce\u5bf9\u771f\u5b9e\u6587\u672c\u7684\u91cd\u89c6\u8fdc\u8d85\u8fc7alt\u6587\u672c(\u56e0\u4e3a\u5df2\u7ecf\u6709\u592a\u591a\u7f51\u7ad9\u4f7f\u7528alt\u6587\u672c\u5145\u5f53\u5173\u952e\u5b57)\uff0c\u56e0\u6b64\uff0c\u6211\u4eec\u5f97\u7528\u53e6\u4e00\u79cd\u65b9\u6cd5\uff1a&lt;h1&gt;&lt;span&gt;Buy widgets&lt;\/span&gt;&lt;\/h1&gt; \u90a3\u4f60\u7684\u6f02\u4eae\u5b57\u4f53\u600e\u4e48\u529e\u5462?\u4e0b\u9762\u7684css\u53ef\u4ee5\u5e2e\u4e0a\u5fd9\uff1a<\/p>\n<p>h1 {<br \/>\nbackground: url(widget-image.gif) no-repeat;<br \/>\n}<br \/>\nh1 span {<br \/>\nposition: absolute;<br \/>\nleft:-2000px;<br \/>\n}<\/p>\n<p>\u73b0\u5728\u4f60\u65e2\u7528\u4e0a\u4e86\u6f02\u4eae\u7684\u56fe\u7247\u53c8\u5f88\u597d\u7684\u9690\u85cf\u4e86\u771f\u5b9e\u6587\u672c\u2014\u2014\u501f\u52a9css\uff0c\u6587\u672c\u88ab\u5b9a\u4f4d\u4e8e\u5c4f\u5e55\u5de6\u4fa7-2000\u50cf\u7d20\u5904\u3002<\/p>\n<p>6. css\u76d2\u6a21\u578bhack\u7684\u53e6\u4e00\u9009\u62e9<\/p>\n<p>css\u76d2\u6a21\u578bhack\u88ab\u7528\u6765\u89e3\u51b3IE6\u4e4b\u524d\u7684\u6d4f\u89c8\u5668\u663e\u793a\u95ee\u9898\uff0cIE6.0\u4e4b\u524d\u7684\u7248\u672c\u4f1a\u628a\u67d0\u5143\u7d20\u7684\u8fb9\u6846\u503c\u548c\u586b\u5145\u503c\u5305\u542b\u5728\u5bbd\u5ea6\u4e4b\u5185(\u800c\u4e0d\u662f\u52a0\u5728\u5bbd\u5ea6\u503c\u4e0a)\u3002\u4f8b\u5982\uff0c\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528\u4ee5\u4e0bcss\u6765\u6307\u5b9a\u67d0\u4e2a\u5bb9\u5668\u7684\u5c3a\u5bf8\uff1a<\/p>\n<p>#box {<br \/>\nwidth: 100px;<br \/>\nborder: 5px;<br \/>\npadding: 20px;<br \/>\n}<\/p>\n<p>\u7136\u540e\u5728html\u4e2d\u5e94\u7528\uff1a&lt;div id=&#8221;box&#8221;&gt;&#8230;&lt;\/div&gt;\uff0c\u76d2\u7684\u603b\u5bbd\u5ea6\u5728\u51e0\u4e4e\u6240\u6709\u6d4f\u89c8\u5668\u4e2d\u4e3a150\u50cf\u7d20(100\u50cf\u7d20\u5bbd\u5ea6+\u4e24\u67615\u50cf\u7d20\u7684\u8fb9\u6846+\u4e24\u4e2a20\u50cf\u7d20\u7684\u586b\u5145)\uff0c\u552f\u72ec\u5728IE6\u4e4b\u524d\u7248\u672c\u7684\u6d4f\u89c8\u5668\u4e2d\u4ecd\u7136\u4e3a100\u50cf\u7d20(\u8fb9\u6846\u503c\u548c\u586b\u5145\u503c\u5305\u542b\u5728\u5bbd\u5ea6\u503c\u4e2d)\uff0c\u76d2\u6a21\u578b\u7684hack\u6b63\u662f\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0c\u4f46\u662f\u4e5f\u4f1a\u5e26\u6765\u9ebb\u70e6\u3002\u66f4\u7b80\u5355\u7684\u529e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<p>css:<\/p>\n<p>#box {<br \/>\nwidth: 150px;<br \/>\n}<br \/>\n#box div {<br \/>\nborder: 5px;<br \/>\npadding: 20px;<br \/>\n}<\/p>\n<p>html:<\/p>\n<p>&lt;div id=&#8221;box&#8221;&gt;&lt;div&gt;&#8230;&lt;\/div&gt;&lt;\/div&gt;<\/p>\n<p>\u8fd9\u6837\u4e00\u6765\u5728\u4efb\u4f55\u6d4f\u89c8\u5668\u4e2d\u76d2\u7684\u603b\u5bbd\u5ea6\u90fd\u5c06\u662f150\u50cf\u7d20\u3002<\/p>\n<p>7. \u5c06\u5757\u5143\u7d20\u5c45\u4e2d<\/p>\n<p>\u5047\u8bbe\u4f60\u7684\u7f51\u7ad9\u4f7f\u7528\u4e86\u56fa\u5b9a\u5bbd\u5ea6\u7684\u5e03\u5c40\uff0c\u6240\u6709\u7684\u5185\u5bb9\u7f6e\u4e8e\u5c4f\u5e55\u4e2d\u592e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u7684css\uff1a<\/p>\n<p>#content {<br \/>\nwidth: 700px;<br \/>\nmargin: 0 auto;<br \/>\n}<\/p>\n<p>\u4f60\u53ef\u4ee5\u628ahtml\u7684body\u4e4b\u5185\u4efb\u4f55\u9879\u76ee\u7f6e\u4e8e<\/p>\n<p>\u4e2d\uff0c\u8be5\u9879\u76ee\u5c06\u81ea\u52a8\u83b7\u5f97\u76f8\u7b49\u7684\u5de6\u53f3\u8fb9\u754c\u503c\u4ece\u800c\u4fdd\u8bc1\u4e86\u5c45\u4e2d\u663e\u793a\u3002\u4e0d\u8fc7\uff0c\u8fd9\u5728IE6\u4e4b\u524d\u7248\u672c\u7684\u6d4f\u89c8\u5668\u4e2d\u4ecd\u7136\u6709\u95ee\u9898\uff0c\u5c06\u4e0d\u4f1a\u5c45\u4e2d\uff0c\u56e0\u6b64\u5fc5\u987b\u4fee\u6539\u5982\u4e0b\uff1a<\/p>\n<p>body {<br \/>\ntext-align: center;<br \/>\n}<br \/>\n#content {<br \/>\ntext-align: left;<br \/>\nwidth: 700px;<br \/>\nmargin: 0 auto;<br \/>\n}<\/p>\n<p>\u5bf9body\u7684\u8bbe\u5b9a\u5c06\u5bfc\u81f4\u4e3b\u4f53\u5185\u5bb9\u5c45\u4e2d\uff0c\u4f46\u662f\u8fde\u6240\u6709\u7684\u6587\u5b57\u4e5f\u5c45\u4e2d\u4e86\uff0c\u8fd9\u6050\u6015\u4e0d\u662f\u4f60\u60f3\u8981\u7684\u6548\u679c\uff0c\u4e3a\u6b64#content \u7684div\u8fd8\u8981\u6307\u5b9a\u4e00\u4e2a\u503c\uff1atext-align: left\u3002<\/p>\n<p>8. \u4f7f\u7528css\u5b9e\u73b0\u5782\u76f4\u5c45\u4e2d<\/p>\n<p>\u5782\u76f4\u5c45\u4e2d\u5bf9\u8868\u683c\u6765\u8bf4\u662f\u5c0f\u83dc\u4e00\u789f\uff0c\u53ea\u9700\u6307\u5b9a\u5355\u5143\u683c\u4e3a vertical-align: middle \u5373\u53ef\uff0c\u4f46\u8fd9\u5728css\u5e03\u5c40\u4e2d\u4e0d\u7ba1\u7528\u3002\u5047\u8bbe\u4f60\u5c06\u4e00\u4e2a\u5bfc\u822a\u83dc\u5355\u7684\u9ad8\u5ea6\u8bbe\u4e3a2em\uff0c\u7136\u540e\u5728css\u4e2d\u6307\u5b9a\u5782\u76f4\u5bf9\u9f50\u7684\u89c4\u5219\uff0c\u6587\u5b57\u8fd8\u662f\u4f1a\u88ab\u6392\u5230\u76d2\u7684\u9876\u90e8\uff0c\u6839\u672c\u6ca1\u6709\u4ec0\u4e48\u533a\u522b\u3002<\/p>\n<p>\u8981\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\uff0c\u53ea\u9700\u5c06\u76d2\u7684\u884c\u9ad8\u8bbe\u4e3a\u4e0e\u76d2\u7684\u9ad8\u5ea6\u76f8\u540c\u5373\u53ef\uff0c\u4ee5\u8fd9\u4e2a\u4f8b\u5b50\u6765\u8bf4\uff0c\u76d2\u9ad82em\uff0c\u90a3\u4e48\u53ea\u9700\u5728css\u4e2d\u518d\u52a0\u5165\u4e00\u6761\uff1aline-height: 2em \u5c31\u53ef\u5b9e\u73b0\u5782\u76f4\u5c45\u4e2d\u4e86!<\/p>\n<p>9. \u5bb9\u5668\u5185\u7684css\u5b9a\u4f4d<\/p>\n<p>css\u7684\u6700\u5927\u4f18\u70b9\u4e4b\u4e00\u5c31\u662f\u53ef\u4ee5\u5c06\u5bf9\u8c61\u5b9a\u4f4d\u5728\u6587\u6863\u7684\u4efb\u4f55\u4f4d\u7f6e\uff0c\u540c\u6837\u7684\u4e5f\u53ef\u4ee5\u5c06\u5bf9\u8c61\u5728\u67d0\u5bb9\u5668\u5185\u8fdb\u884c\u5b9a\u4f4d\u3002\u53ea\u9700\u8981\u4e3a\u8be5\u5bb9\u5668\u6dfb\u52a0\u4e00\u6761css\u89c4\u5219\uff1a<\/p>\n<p>#container {<br \/>\nposition: relative;<br \/>\n}<\/p>\n<p>\u5219\u5bb9\u5668\u5185\u7684\u4efb\u4f55\u5143\u7d20\u7684\u5b9a\u4f4d\u90fd\u662f\u76f8\u5bf9\u4e8e\u8be5\u5bb9\u5668\u7684\u3002\u5047\u5b9a\u4f60\u4f7f\u7528\u4ee5\u4e0bhtml\u7ed3\u6784\uff1a<\/p>\n<p>&lt;div id=&#8221;container&#8221;&gt;&lt;div id=&#8221;navigation&#8221;&gt;&#8230;&lt;\/div&gt;&lt;\/div&gt;<\/p>\n<p>\u5982\u679c\u60f3\u5c06navigation\u5b9a\u4f4d\u5728\u5bb9\u5668\u5185\u79bb\u5de6\u8fb9\u754c30\u50cf\u7d20\uff0c\u79bb\u9876\u90e85\u50cf\u7d20\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0bcss\u8bed\u53e5\uff1a<\/p>\n<p>#navigation {<br \/>\nposition: absolute;<br \/>\nleft: 30px;<br \/>\ntop: 5px;<br \/>\n}<\/p>\n<p>10. \u5ef6\u4f38\u81f3\u5c4f\u5e55\u5e95\u90e8\u7684\u80cc\u666f\u8272<\/p>\n<p>css\u7684\u7f3a\u70b9\u4e4b\u4e00\u662f\u7f3a\u4e4f\u5782\u76f4\u65b9\u5411\u7684\u63a7\u5236\uff0c\u4ece\u800c\u5bfc\u81f4\u4e86\u4e00\u4e2a\u8868\u683c\u5e03\u5c40\u4e0d\u4f1a\u9047\u5230\u7684\u95ee\u9898\u3002\u5047\u8bbe\u4f60\u5728\u9875\u9762\u7684\u5de6\u4fa7\u8bbe\u5b9a\u4e86\u4e00\u5217\u7528\u4e8e\u653e\u7f6e\u7f51\u7ad9\u7684\u5bfc\u822a\u3002\u9875\u9762\u4e3a\u767d\u8272\u80cc\u666f\uff0c\u4f46\u4f60\u5e0c\u671b\u5bfc\u822a\u6240\u5728\u7684\u5217\u4e3a\u84dd\u8272\u80cc\u666f\uff0c\u4f7f\u7528\u4ee5\u4e0bcss\u5373\u53ef\uff1a<\/p>\n<p>#navigation {<br \/>\nbackground: blue;<br \/>\nwidth: 150px;<br \/>\n}<\/p>\n<p>\u95ee\u9898\u5728\u4e8e\u5bfc\u822a\u9879\u4e0d\u4f1a\u4e00\u76f4\u5ef6\u4f38\u5230\u9875\u9762\u7684\u5e95\u90e8\uff0c\u81ea\u7136\u5b83\u7684\u80cc\u666f\u8272\u4e5f\u4e0d\u4f1a\u5ef6\u4f38\u5230\u5e95\u90e8\u3002\u4e8e\u662f\u5de6\u5217\u7684\u84dd\u8272\u80cc\u666f\u5728\u9875\u9762\u4e0a\u88ab\u534a\u8def\u622a\u65ad\uff0c\u6d6a\u8d39\u4e86\u4f60\u7684\u4e00\u756a\u8bbe\u8ba1\u3002\u600e\u4e48\u529e\u5462?\u5f88\u4e0d\u5e78\u6211\u4eec\u73b0\u5728\u53ea\u80fd\u7528\u6b3a\u9a97\u7684\u529e\u6cd5\uff0c\u5373\u5c06body\u7684\u80cc\u666f\u6307\u5b9a\u4e3a\u4e0e\u5de6\u5217\u540c\u989c\u8272\u540c\u5bbd\u5ea6\u7684\u56fe\u7247\uff0ccss\u5982\u4e0b\uff1a<\/p>\n<p>body {<br \/>\nbackground: url(blue-image.gif) 0 0 repeat-y;<br \/>\n}<\/p>\n<p>\u80cc\u666f\u56fe\u5e94\u4e3a\u5bbd150\u50cf\u7d20\u7684\u84dd\u8272\u56fe\u7247\u3002\u8fd9\u4e00\u529e\u6cd5\u7684\u7f3a\u70b9\u662f\u6ca1\u6cd5\u4f7f\u7528em\u6765\u6307\u5b9a\u5de6\u5217\u7684\u5bbd\u5ea6\uff0c\u5f53\u7528\u6237\u6539\u53d8\u6587\u5b57\u7684\u5927\u5c0f\u5bfc\u81f4\u5185\u5bb9\u7684\u5bbd\u5ea6\u6269\u5f20\u65f6\uff0c\u80cc\u666f\u8272\u7684\u5bbd\u5ea6\u4e0d\u4f1a\u968f\u4e4b\u6539\u53d8\u3002\u5230\u5199\u8fd9\u7bc7\u6587\u7ae0\u4e3a\u6b62\u8fd9\u662f\u5bf9\u8fd9\u7c7b\u95ee\u9898\u7684\u552f\u4e00\u89e3\u51b3\u529e\u6cd5\uff0c\u56e0\u6b64\u4f60\u53ea\u80fd\u4e3a\u5de6\u5217\u4f7f\u7528\u50cf\u7d20\u503c\u6765\u83b7\u5f97\u80fd\u591f\u81ea\u52a8\u5ef6\u4f38\u7684\u4e0d\u540c\u7684\u80cc\u666f\u8272\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u7f29\u5199\u53ef\u4ee5\u5e2e\u52a9\u51cf\u5c11\u4f60CSS\u6587\u4ef6\u7684\u5927\u5c0f\uff0c\u66f4\u52a0\u5bb9\u6613\u9605\u8bfb\u3002css\u7f29\u5199\u7684\u4e3b\u8981\u89c4\u5219\u5982\u4e0b\uff1a \u989c\u8272 16\u8fdb\u5236\u7684\u8272\u5f69\u503c\uff0c\u5982\u679c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6],"tags":[],"class_list":["post-325","post","type-post","status-publish","format-standard","hentry","category-code_related"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/325","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=325"}],"version-history":[{"count":1,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/325\/revisions"}],"predecessor-version":[{"id":5303,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/325\/revisions\/5303"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=325"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=325"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=325"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}