{"id":28429,"date":"2024-11-24T16:42:37","date_gmt":"2024-11-24T08:42:37","guid":{"rendered":"https:\/\/fwq.ai\/blog\/28429\/"},"modified":"2024-11-24T16:42:37","modified_gmt":"2024-11-24T08:42:37","slug":"css-%e5%b9%b6%e4%b8%8d%e9%9a%be%ef%bc%88%e4%bd%a0%e5%8f%aa%e6%98%af%e7%bc%ba%e5%b0%91%e8%bf%99%e4%ba%9b%e5%9f%ba%e7%a1%80%e7%9f%a5%e8%af%86%ef%bc%89","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/28429\/","title":{"rendered":"CSS \u5e76\u4e0d\u96be\uff08\u4f60\u53ea\u662f\u7f3a\u5c11\u8fd9\u4e9b\u57fa\u7840\u77e5\u8bc6\uff09"},"content":{"rendered":"<p>\u5f53\u6211\u7b2c\u4e00\u6b21\u5f00\u59cb web \u5f00\u53d1\u65f6\uff0c\u6211\u8ba4\u4e3a\u6211\u6700\u5927\u7684\u6311\u6218\u662f javascript\uff08\u5e76\u4e0d\u662f\u8bf4 js \u8fd8\u4e0d\u662f\u5c11\u6570\uff09\uff0c\u4f46\u968f\u540e\u51fa\u73b0\u4e86\u5f88\u591a\u5173\u4e8e  \u7684\u7cdf\u7cd5\u8868\u73b0\u548c\u6050\u6016\u6545\u4e8b\u3002 <\/p>\n<p>\u5c3d\u7ba1\u5982\u6b64\uff0c\u6211\u8fd8\u662f\u6df1\u5165\u7814\u7a76\u4e86\u524d\u7aef\u5f00\u53d1\uff0c\u5929\u54ea\uff0ccss \u5bf9\u6211\u505a\u4e86\u5f88\u591a\u5de5\u4f5c\u3002\u6ca1\u6709\u4ec0\u4e48\u8fdb\u5c55\u987a\u5229\uff0c\u751a\u81f3\u6ca1\u6709\u8ba9\u6211\u5f00\u59cb\u5c06 div \u5c45\u4e2d\u3002\u8fd9\u662f\u4e00\u573a\u5669\u68a6\u3002 <\/p>\n<p>\u4f46\u662f\uff0c\u7136\u540e\uff0c\u6211\u610f\u8bc6\u5230\uff0ccss \u4e0d\u662f\u95ee\u9898\uff0c\u95ee\u9898\u662f\u6211\u4e0d\u4e86\u89e3\u57fa\u7840\u77e5\u8bc6\uff0c\u4e00\u65e6\u6211\u638c\u63e1\u4e86\u5b83\u4eec\uff0c\u6837\u5f0f\u5c31\u53d8\u5f97\u66f4\u5bb9\u6613\u5e76\u4e14\u4ee4\u4eba\u60ca\u8bb6\u5730\u6709\u8da3\u3002 <\/p>\n<p>\u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u5f15\u5bfc\u60a8\u4e86\u89e3\u4e24\u4e2a\u57fa\u672c\u6982\u5ff5\uff0c\u8fd9\u5c06\u4e3a\u638c\u63e1 css \u5960\u5b9a\u57fa\u7840\uff1a<\/p>\n<ol>\n<li>css \u9009\u62e9\u5668<\/li>\n<li>\u76d2\u5b50\u6a21\u578b<\/li>\n<li>\u5b9a\u4f4d\u548c\u5e03\u5c40<\/li>\n<\/ol>\n<ul>\n<li> <strong>css \u9009\u62e9\u5668<\/strong>\uff1acss \u9009\u62e9\u5668\u662f\u8ba9\u60a8\u5b9a\u4f4d\u67d0\u4e9b\u9700\u8981\u6837\u5f0f\u5316\u7684 html \u5143\u7d20\u7684\u5de5\u5177\u3002 <\/li>\n<\/ul>\n<p>\u8ba9\u6211\u4eec\u63a2\u7d22\u4e00\u4e9b\u5e38\u7528\u7684\u9009\u62e9\u5668\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<p><strong>a.\u901a\u7528\u9009\u62e9\u5668\uff1a<\/strong> \u7528\u4e8e\u5b9a\u4f4d\u9875\u9762\u4e0a\u7684\u6bcf\u4e2a\u5143\u7d20\u3002\u5b83\u7531\u661f\u53f7\uff08*\uff09\u8868\u793a\uff0c\u901a\u5e38\u7528\u4e8e\u5168\u5c40\u91cd\u7f6e\u6216\u5e94\u7528\u57fa\u672c\u6837\u5f0f\u3002<\/p>\n<pre>*{\nmargin: 0;\npadding: 0;\nbox-sizing: border-box;\n}\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>b.\u7c7b\u9009\u62e9\u5668\uff1a<\/strong> \u7528\u4e8e\u9009\u62e9\u5177\u6709\u7279\u5b9a\u7c7b\u5c5e\u6027\u503c\u7684 html \u5143\u7d20\u3002\u8981\u9009\u62e9\u5177\u6709\u7279\u5b9a\u7c7b\u7684\u5143\u7d20\uff0c\u8bf7\u5199\u4e00\u4e2a\u53e5\u70b9(.)\uff0c\u540e\u8ddf\u7c7b\u5c5e\u6027\u7684\u503c\u3002<\/p>\n<pre>&lt;div class=\"box\"&gt;&lt;\/div&gt;\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>.box{\n  background-color: teal;\n  padding: 30px;\n  border-radius: 10px;\n  border: 2px solid;\n  text-align: center;\n}\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>c.\u7c7b\u578b\u9009\u62e9\u5668\uff1a<\/strong> \u7528\u4e8e\u5b9a\u4f4d\u7279\u5b9a\u7c7b\u578b\u7684\u6240\u6709\u5143\u7d20\u3002\u5b83\u4e5f\u79f0\u4e3a\u5143\u7d20\u9009\u62e9\u5668\u3002<\/p>\n<pre>p{\ntext-align: center;\nfont-size: 1.2rem\n}\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u7528\u4f8b\uff1a\u8fd9\u5bf9\u6240\u6709 <\/p>\n<p>tags \u5e94\u7528\u7edf\u4e00\u7684\u6837\u5f0f\u3002<\/p>\n<p><strong>d.\uff1a<\/strong> \u6b64\u9009\u62e9\u5668\u6839\u636e html \u5143\u7d20\u7684\u5c5e\u6027\u548c\u503c\u6765\u5b9a\u4f4d html \u5143\u7d20\u3002<\/p>\n<pre>\ninput[type = \"text\"] {\nbackground-color: cyan;\ncolor: gray;\n}\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>e.\u4f2a\u7c7b\uff1a<\/strong> \u8fd9\u4e9b\u6839\u636e\u5176\u72b6\u6001\u9009\u62e9\u6837\u5f0f\u5143\u7d20\u3002<\/p>\n<pre>a:hover{\ncolor: blue;\ntransition: ease-in 0.5s;\n}\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd8\u6709\u5176\u4ed6\u6709\u7528\u7684 css \u9009\u62e9\u5668\uff0c\u4f46\u76ee\u524d\u5c31\u8fd9\u4e9b\u3002<\/p>\n<ul>\n<li><strong>\u76d2\u5b50\u6a21\u578b<\/strong><\/li>\n<\/ul>\n<p>\u76d2\u5b50\u6a21\u578b\u672c\u8d28\u4e0a\u662f\u4e00\u4e2a\u5305\u88f9 html \u5143\u7d20\u7684\u76d2\u5b50\uff0c\u57fa\u672c\u4e0a html \u4e2d\u7684\u6bcf\u4e2a\u5143\u7d20\u53ea\u662f\u4e00\u4e2a\u5927\uff08\u6216\u5c0f\uff09\u7684\u77e9\u5f62\u76d2\u5b50\u3002\u76d2\u5b50\u6a21\u578b\u7684\u4f5c\u7528\u662f\u5e2e\u52a9\u63a7\u5236\u6bcf\u4e2a\u76d2\u5b50\u5360\u7528\u7684\u7a7a\u95f4\u4ee5\u53ca\u5b83\u4eec\u5982\u4f55\u4e0e\u5176\u4ed6\u5143\u7d20\u4ea4\u4e92\u3002 <\/p>\n<p>\u6bcf\u4e2a\u76d2\u5b50\u6709\u56db\u4e2a\u4e3b\u8981\u90e8\u5206\uff1a<\/p>\n<p><strong>1\u3002\u5185\u5bb9\uff1a<\/strong> \u8fd9\u662f\u76d2\u5b50\u91cc\u9762\u7684\u5185\u5bb9\u2014\u2014\u6587\u672c\u3001\u56fe\u50cf\u548c\u5176\u4ed6\u5143\u7d20\u3002 <br \/><strong>2.\u586b\u5145\uff1a<\/strong> \u8fd9\u662f\u5185\u5bb9\u548c\u6846\u8fb9\u7f18\u4e4b\u95f4\u7684\u7a7a\u95f4\u3002 <br \/><strong>3.\u8fb9\u6846\uff1a<\/strong> \u8fd9\u662f\u76d2\u5b50\u7684\u8fb9\u7f18\u3002 <br \/><strong>4.\u8fb9\u8ddd\uff1a<\/strong> \u8fd9\u662f\u8fb9\u6846\u4e4b\u5916\u7684\u7a7a\u95f4\uff0c\u5c06\u8be5\u6846\u4e0e\u5176\u4ed6\u6846\u5206\u5f00\u3002 <\/p>\n<p>\u8fd9\u662f\u89e3\u91ca\u76d2\u5b50\u6a21\u578b\u7684\u63d2\u56fe<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173211297892718.jpg\" class=\"aligncenter\" title=\"CSS \u5e76\u4e0d\u96be\uff08\u4f60\u53ea\u662f\u7f3a\u5c11\u8fd9\u4e9b\u57fa\u7840\u77e5\u8bc6\uff09\u63d2\u56fe\" alt=\"CSS \u5e76\u4e0d\u96be\uff08\u4f60\u53ea\u662f\u7f3a\u5c11\u8fd9\u4e9b\u57fa\u7840\u77e5\u8bc6\uff09\u63d2\u56fe\" \/><\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u865a\u7ebf\u662f\u76d2\u5b50\u7684\u8fb9\u6846\u3002<\/p>\n<p>\u76d2\u5b50\u6a21\u578b\u5bf9\u4e8e\u60a8\u60f3\u8981\u5728 css \u4e2d\u6267\u884c\u7684\u4efb\u4f55\u64cd\u4f5c\u90fd\u662f\u5fc5\u4e0d\u53ef\u5c11\u7684\uff0c\u4ece\u5b9a\u4f4d\u5143\u7d20\u5230\u7ba1\u7406\u95f4\u8ddd\u3002\u4f8b\u5982\uff0c\u6211\u4ec5\u4f7f\u7528 html \u548c css \u7ed8\u5236\u4e86\u76d2\u5b50\u6a21\u578b\u63d2\u56fe\uff0c\u4ee5\u5c55\u793a\u4e0d\u540c\u5c42\u5982\u4f55\u534f\u540c\u5de5\u4f5c\u3002<\/p>\n<p>\u8fd9\u662f\u5e2e\u52a9\u6211\u5c06\u63d2\u56fe\u53d8\u4e3a\u73b0\u5b9e\u7684\u4ee3\u7801\uff1a<\/p>\n<pre>&lt;!doctype html&gt;\n&lt;html lang=\"en\"&gt;\n&lt;head&gt;\n    &lt;meta charset=\"utf-8\"&gt;\n    &lt;meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"&gt;\n    &lt;title&gt;visualizing the css box model&lt;\/title&gt;\n    &lt;link rel=\"stylesheet\" href=\"style.css\"&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;div class=\"box\"&gt;\n      &lt;div class=\"margin\"&gt;\n        &lt;p&gt;the margin&lt;\/p&gt;\n        &lt;div class=\"border\"&gt;\n\n            &lt;p&gt;the border&lt;\/p&gt;\n\n            &lt;div class=\"padding\"&gt;\n                &lt;p&gt;the padding&lt;\/p&gt;\n                &lt;div class=\"content\"&gt;\n                    &lt;p&gt;the content of the box&lt;\/p&gt;\n                &lt;\/div&gt;\n            &lt;\/div&gt;\n        &lt;\/div&gt;\n      &lt;\/div&gt;\n    &lt;\/div&gt;\n\n&lt;\/body&gt;\n&lt;\/html&gt;\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<pre>* {\n  margin: 0;\n  padding: 0;\n  box-sizing: border-box;\n}\n\nbody {\n  font-family: Arial, sans-serif;\n  background-color: bisque;\n  color: white;\n  display: grid;\n  place-content: center;\n  height: 100vh;\n}\n\n.other-box {\n  width: 200px;\n  height: 100px;\n  padding: 20px;\n  border: 2px solid black;\n  margin: 15px;\n}\n.border {\n  border: 2px dashed black;\n  padding: 20px;\n  border-radius: 10px;\n  background-color: rgb(255, 255, 255);\n  color: black;\n  text-align: center;\n}\n\n.margin {\n  background-color: teal;\n  margin: 50px;\n  border: 1px solid goldenrod;\n  border-radius: 10px;\n  padding: 30px;\n  text-align: center;\n  color: black;\n}\n\n.padding {\n  background-color: teal;\n  padding: 30px;\n  border-radius: 10px;\n  border: 2px solid;\n  text-align: center;\n}\n\n.content {\n  background-color: rgb(255, 255, 255);\n  padding: 20px;\n  color: black;\n  text-align: center;\n  border: 2px solid;\n  border-radius: 10px;\n}\n\np {\n  font-size: 20px;\n  margin-bottom: 10px;\n}\n\n<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u603b\u7ed3<\/strong>\uff08\u65f6\u95f4\u5230\u4e86\uff09<br \/> css \u4e00\u5f00\u59cb\u53ef\u80fd\u770b\u8d77\u6765\u5f88\u591a\uff0c\u4f46\u662f\u4e00\u65e6\u4f60\u638c\u63e1\u4e86\u57fa\u7840\u77e5\u8bc6\uff0c\u4f60\u5c31\u5df2\u7ecf\u51c6\u5907\u597d\u5f81\u670d\u4e16\u754c\uff08\u81f3\u5c11\u662f\u4f60\u7684\u4e16\u754c\uff09\u3002 <br \/><strong>\u8fd9\u662f\u672c\u6587\u7684\u8981\u70b9<\/strong>\uff1acss \u5e76\u4e0d\u96be\uff0c\u4f60\u53ea\u9700\u8981\u66f4\u591a\u5730\u5173\u6ce8\u57fa\u7840\u77e5\u8bc6\u3002 <br \/> \u7ee7\u7eed\u5b66\u4e60\uff0c\u6700\u91cd\u8981\u7684\u662f\u7ee7\u7eed\u7ec3\u4e60\uff0c\u5f88\u5feb\uff0c\u60a8\u5c31\u4f1a\u50cf\u4e13\u4e1a\u4eba\u58eb\u4e00\u6837\u8bbe\u8ba1\u7f51\u9875\u3002<\/p>\n<p><strong>\u4e0b\u4e00\u6b65\u662f\u4ec0\u4e48\uff1f<\/strong><br \/> \u73b0\u5728\u60a8\u5df2\u7ecf\u5b66\u4e60\u4e86 css \u9009\u62e9\u5668\u548c\u76d2\u5b50\u6a21\u578b\u7684\u57fa\u7840\u77e5\u8bc6\uff0c\u60a8\u79bb\u638c\u63e1 css \u53c8\u8fd1\u4e86\u4e00\u6b65\uff0c\u4f46\u8fd8\u6709\u66f4\u591a\u4e1c\u897f\u9700\u8981\u63a2\u7d22\u3002<br \/> \u5728\u4e0b\u4e00\u7bc7\u6587\u7ae0\u4e2d\uff0c\u6211\u4eec\u5c06\u6df1\u5165\u63a2\u8ba8 css \u5b9a\u4f4d\u548c\u5e03\u5c40\u6280\u672f\uff0c\u4f8b\u5982 flexbox \u548c grid\u3002<\/p>\n<p>\u7f16\u7801\u6109\u5feb\uff01\uff01\uff01<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fCSS \u5e76\u4e0d\u96be\uff08\u4f60\u53ea\u662f\u7f3a\u5c11\u8fd9\u4e9b\u57fa\u7840\u77e5\u8bc6\uff09\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5f53\u6211\u7b2c\u4e00\u6b21\u5f00\u59cb web \u5f00\u53d1\u65f6\uff0c\u6211\u8ba4\u4e3a\u6211\u6700\u5927\u7684\u6311\u6218\u662f javascript\uff08\u5e76\u4e0d\u662f\u8bf4 js \u8fd8\u4e0d\u662f\u5c11\u6570\uff09\uff0c\u4f46\u968f\u540e\u51fa\u73b0\u4e86\u5f88\u591a\u5173\u4e8e \u7684\u7cdf\u7cd5\u8868\u73b0\u548c\u6050\u6016\u6545\u4e8b\u3002 \u5c3d\u7ba1\u5982\u6b64\uff0c\u6211\u8fd8\u662f\u6df1\u5165\u7814\u7a76\u4e86\u524d\u7aef\u5f00\u53d1\uff0c\u5929\u54ea\uff0ccss \u5bf9\u6211\u505a\u4e86\u5f88\u591a\u5de5\u4f5c\u3002\u6ca1\u6709\u4ec0\u4e48\u8fdb\u5c55\u987a\u5229\uff0c\u751a\u81f3\u6ca1\u6709\u8ba9\u6211\u5f00\u59cb\u5c06 div \u5c45\u4e2d\u3002\u8fd9\u662f\u4e00\u573a\u5669\u68a6\u3002 \u4f46\u662f\uff0c\u7136\u540e\uff0c\u6211\u610f\u8bc6\u5230\uff0ccss \u4e0d\u662f\u95ee\u9898\uff0c\u95ee\u9898\u662f\u6211\u4e0d\u4e86\u89e3\u57fa\u7840\u77e5\u8bc6\uff0c\u4e00\u65e6\u6211\u638c\u63e1\u4e86\u5b83\u4eec\uff0c\u6837\u5f0f\u5c31\u53d8\u5f97\u66f4\u5bb9\u6613\u5e76\u4e14\u4ee4\u4eba\u60ca\u8bb6\u5730\u6709\u8da3\u3002 \u5728\u672c\u6587\u4e2d\uff0c\u6211\u5c06\u5f15\u5bfc\u60a8\u4e86\u89e3\u4e24\u4e2a\u57fa\u672c\u6982\u5ff5\uff0c\u8fd9\u5c06\u4e3a\u638c\u63e1 css \u5960\u5b9a\u57fa\u7840\uff1a css \u9009\u62e9\u5668 \u76d2\u5b50\u6a21\u578b \u5b9a\u4f4d\u548c\u5e03\u5c40 css \u9009\u62e9\u5668\uff1acss \u9009\u62e9\u5668\u662f\u8ba9\u60a8\u5b9a\u4f4d\u67d0\u4e9b\u9700\u8981\u6837\u5f0f\u5316\u7684 html \u5143\u7d20\u7684\u5de5\u5177\u3002 \u8ba9\u6211\u4eec\u63a2\u7d22\u4e00\u4e9b\u5e38\u7528\u7684\u9009\u62e9\u5668\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b a.\u901a\u7528\u9009\u62e9\u5668\uff1a \u7528\u4e8e\u5b9a\u4f4d\u9875\u9762\u4e0a\u7684\u6bcf\u4e2a\u5143\u7d20\u3002\u5b83\u7531\u661f\u53f7\uff08*\uff09\u8868\u793a\uff0c\u901a\u5e38\u7528\u4e8e\u5168\u5c40\u91cd\u7f6e\u6216\u5e94\u7528\u57fa\u672c\u6837\u5f0f\u3002 *{ margin: 0; padding: 0; box-sizing: border-box; } \u767b\u5f55\u540e\u590d\u5236 b.\u7c7b\u9009\u62e9\u5668\uff1a \u7528\u4e8e\u9009\u62e9\u5177\u6709\u7279\u5b9a\u7c7b\u5c5e\u6027\u503c\u7684 html \u5143\u7d20\u3002\u8981\u9009\u62e9\u5177\u6709\u7279\u5b9a\u7c7b\u7684\u5143\u7d20\uff0c\u8bf7\u5199\u4e00\u4e2a\u53e5\u70b9(.)\uff0c\u540e\u8ddf\u7c7b\u5c5e\u6027\u7684\u503c\u3002 &lt;div class=&#8221;box&#8221;&gt;&lt;\/div&gt; \u767b\u5f55\u540e\u590d\u5236 .box{ background-color: teal; padding: 30px; border-radius: 10px; border: 2px solid; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-28429","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28429","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=28429"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/28429\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=28429"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=28429"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=28429"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}