{"id":15013,"date":"2024-09-20T10:06:52","date_gmt":"2024-09-20T02:06:52","guid":{"rendered":"https:\/\/fgchen.com\/wpedu\/?p=15013"},"modified":"2026-03-30T14:29:35","modified_gmt":"2026-03-30T06:29:35","slug":"css-cheat-sheet-%e9%80%9f%e8%a8%98%e8%a1%a8","status":"publish","type":"post","link":"https:\/\/fgchen.com\/wpedu\/2024\/09\/css-cheat-sheet-%e9%80%9f%e8%a8%98%e8%a1%a8\/","title":{"rendered":"CSS Cheat Sheet \u901f\u8a18\u8868"},"content":{"rendered":"<hr \/>\n<h1><strong>CSS Cheat Sheet<\/strong><\/h1>\n<h2>1. <strong>CSS \u57fa\u672c\u8a9e\u6cd5<\/strong><\/h2>\n<pre><code class=\"language-css\">\u9078\u64c7\u5668 {\n    \u5c6c\u6027: \u503c;\n}<\/code><\/pre>\n<hr \/>\n<h2>2. <strong>\u6587\u5b57\u6a23\u5f0f<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>color<\/code><\/td>\n<td>\u8a2d\u5b9a\u6587\u5b57\u984f\u8272<\/td>\n<td><code>color: red;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>font-size<\/code><\/td>\n<td>\u8a2d\u5b9a\u6587\u5b57\u5927\u5c0f<\/td>\n<td><code>font-size: 16px;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>font-family<\/code><\/td>\n<td>\u8a2d\u5b9a\u5b57\u9ad4<\/td>\n<td><code>font-family: Arial, sans-serif;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>font-weight<\/code><\/td>\n<td>\u8a2d\u5b9a\u5b57\u9ad4\u7c97\u7d30<\/td>\n<td><code>font-weight: bold;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>text-align<\/code><\/td>\n<td>\u5c0d\u9f4a\u6587\u5b57<\/td>\n<td><code>text-align: center;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>line-height<\/code><\/td>\n<td>\u884c\u9ad8<\/td>\n<td><code>line-height: 1.5;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>text-decoration<\/code><\/td>\n<td>\u6dfb\u52a0\u6587\u5b57\u88dd\u98fe\uff08\u5982\u5e95\u7dda\u3001\u522a\u9664\u7dda\u7b49\uff09<\/td>\n<td><code>text-decoration: underline;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>3. <strong>\u76d2\u6a21\u578b\uff08Box Model\uff09<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>width<\/code><\/td>\n<td>\u5143\u7d20\u5bec\u5ea6<\/td>\n<td><code>width: 200px;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>height<\/code><\/td>\n<td>\u5143\u7d20\u9ad8\u5ea6<\/td>\n<td><code>height: 100px;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>margin<\/code><\/td>\n<td>\u5916\u908a\u8ddd\uff08\u5143\u7d20\u5916\u90e8\u7684\u8ddd\u96e2\uff09<\/td>\n<td><code>margin: 20px;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>padding<\/code><\/td>\n<td>\u5167\u908a\u8ddd\uff08\u5167\u5bb9\u8207\u908a\u6846\u4e4b\u9593\u7684\u8ddd\u96e2\uff09<\/td>\n<td><code>padding: 10px;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>border<\/code><\/td>\n<td>\u908a\u6846<\/td>\n<td><code>border: 2px solid black;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>4. <strong>\u80cc\u666f\u6a23\u5f0f<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>background-color<\/code><\/td>\n<td>\u8a2d\u5b9a\u80cc\u666f\u984f\u8272<\/td>\n<td><code>background-color: yellow;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>background-image<\/code><\/td>\n<td>\u8a2d\u5b9a\u80cc\u666f\u5716\u7247<\/td>\n<td><code>background-image: url(&#039;image.jpg&#039;);<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>background-size<\/code><\/td>\n<td>\u8a2d\u5b9a\u80cc\u666f\u5716\u7247\u5927\u5c0f<\/td>\n<td><code>background-size: cover;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>background-position<\/code><\/td>\n<td>\u8a2d\u5b9a\u80cc\u666f\u5716\u7247\u4f4d\u7f6e<\/td>\n<td><code>background-position: center;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>background-repeat<\/code><\/td>\n<td>\u8a2d\u5b9a\u80cc\u666f\u662f\u5426\u91cd\u8907<\/td>\n<td><code>background-repeat: no-repeat;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>5. <strong>\u4f48\u5c40<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>display<\/code><\/td>\n<td>\u8a2d\u5b9a\u5143\u7d20\u986f\u793a\u65b9\u5f0f<\/td>\n<td><code>display: block;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>position<\/code><\/td>\n<td>\u8a2d\u5b9a\u5143\u7d20\u5b9a\u4f4d\u65b9\u5f0f<\/td>\n<td><code>position: relative;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>top<\/code>, <code>right<\/code>, <code>bottom<\/code>, <code>left<\/code><\/td>\n<td>\u8a2d\u5b9a\u5143\u7d20\u8ddd\u96e2<\/td>\n<td><code>top: 10px; left: 20px;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>float<\/code><\/td>\n<td>\u6d6e\u52d5\u5143\u7d20<\/td>\n<td><code>float: left;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>clear<\/code><\/td>\n<td>\u6e05\u9664\u6d6e\u52d5<\/td>\n<td><code>clear: both;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>z-index<\/code><\/td>\n<td>\u8a2d\u5b9a\u5806\u758a\u9806\u5e8f<\/td>\n<td><code>z-index: 10;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>overflow<\/code><\/td>\n<td>\u8a2d\u5b9a\u5167\u5bb9\u8d85\u51fa\u908a\u6846\u6642\u7684\u8655\u7406\u65b9\u5f0f<\/td>\n<td><code>overflow: hidden;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>6. <strong>\u908a\u6846\u8207\u5713\u89d2<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>border<\/code><\/td>\n<td>\u8a2d\u5b9a\u5143\u7d20\u908a\u6846<\/td>\n<td><code>border: 1px solid black;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>border-radius<\/code><\/td>\n<td>\u8a2d\u5b9a\u5143\u7d20\u5713\u89d2<\/td>\n<td><code>border-radius: 10px;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>border-top<\/code>, <code>border-right<\/code>, <code>border-bottom<\/code>, <code>border-left<\/code><\/td>\n<td>\u8a2d\u5b9a\u55ae\u908a\u908a\u6846<\/td>\n<td><code>border-top: 2px dashed red;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>7. <strong>\u6e05\u55ae\u6a23\u5f0f<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>list-style-type<\/code><\/td>\n<td>\u8a2d\u5b9a\u5217\u8868\u7b26\u865f\u6a23\u5f0f<\/td>\n<td><code>list-style-type: circle;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>list-style-image<\/code><\/td>\n<td>\u8a2d\u5b9a\u5217\u8868\u7b26\u865f\u70ba\u5716\u7247<\/td>\n<td><code>list-style-image: url(&#039;bullet.png&#039;);<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>8. <strong>CSS \u9078\u64c7\u5668<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u9078\u64c7\u5668<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>*<\/code><\/td>\n<td>\u901a\u914d\u7b26\uff0c\u9078\u64c7\u6240\u6709\u5143\u7d20<\/td>\n<td><code>* { margin: 0; padding: 0; }<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>element<\/code><\/td>\n<td>\u9078\u64c7\u7279\u5b9a HTML \u5143\u7d20<\/td>\n<td><code>p { color: blue; }<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>.classname<\/code><\/td>\n<td>\u9078\u64c7\u64c1\u6709\u7279\u5b9a class \u7684\u5143\u7d20<\/td>\n<td><code>.box { margin: 10px; }<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>#idname<\/code><\/td>\n<td>\u9078\u64c7\u64c1\u6709\u7279\u5b9a ID \u7684\u5143\u7d20<\/td>\n<td><code>#header { background: grey; }<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>element, element<\/code><\/td>\n<td>\u7fa4\u7d44\u9078\u64c7\u5668\uff0c\u9078\u64c7\u591a\u500b\u5143\u7d20<\/td>\n<td><code>h1, p { color: black; }<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>element element<\/code><\/td>\n<td>\u5f8c\u4ee3\u9078\u64c7\u5668\uff0c\u9078\u64c7\u5143\u7d20\u4e2d\u7684\u5143\u7d20<\/td>\n<td><code>div p { color: red; }<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>element &gt; element<\/code><\/td>\n<td>\u5b50\u9078\u64c7\u5668\uff0c\u9078\u64c7\u76f4\u63a5\u5b50\u5143\u7d20<\/td>\n<td><code>div &gt; p { color: green; }<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>element + element<\/code><\/td>\n<td>\u9130\u63a5\u5144\u5f1f\u9078\u64c7\u5668\uff0c\u9078\u64c7\u7dca\u8ddf\u5176\u5f8c\u7684\u5144\u5f1f\u5143\u7d20<\/td>\n<td><code>h1 + p { font-size: 12px; }<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>:hover<\/code><\/td>\n<td>\u9078\u64c7\u9f20\u6a19\u61f8\u505c\u7684\u5143\u7d20<\/td>\n<td><code>a:hover { color: orange; }<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>9. <strong>CSS Flexbox<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>display: flex<\/code><\/td>\n<td>\u555f\u7528\u5f48\u6027\u4f48\u5c40<\/td>\n<td><code>display: flex;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>flex-direction<\/code><\/td>\n<td>\u8a2d\u5b9a\u4e3b\u8ef8\u65b9\u5411<\/td>\n<td><code>flex-direction: row;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>justify-content<\/code><\/td>\n<td>\u6cbf\u4e3b\u8ef8\u5c0d\u9f4a\u5167\u5bb9<\/td>\n<td><code>justify-content: center;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>align-items<\/code><\/td>\n<td>\u6cbf\u4ea4\u53c9\u8ef8\u5c0d\u9f4a\u5167\u5bb9<\/td>\n<td><code>align-items: flex-start;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>10. <strong>CSS Grid<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>display: grid<\/code><\/td>\n<td>\u555f\u7528\u7db2\u683c\u4f48\u5c40<\/td>\n<td><code>display: grid;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>grid-template-columns<\/code><\/td>\n<td>\u8a2d\u5b9a\u5217\u6578\u548c\u5217\u5bec<\/td>\n<td><code>grid-template-columns: 1fr 2fr;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>grid-gap<\/code><\/td>\n<td>\u8a2d\u5b9a\u7db2\u683c\u9593\u8ddd<\/td>\n<td><code>grid-gap: 10px;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>grid-template-rows<\/code><\/td>\n<td>\u8a2d\u5b9a\u884c\u6578\u548c\u884c\u9ad8<\/td>\n<td><code>grid-template-rows: 100px auto;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>11. <strong>\u52d5\u756b\u8207\u904e\u6e21<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>transition<\/code><\/td>\n<td>\u8a2d\u5b9a\u904e\u6e21\u6548\u679c<\/td>\n<td><code>transition: all 0.3s ease;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>animation<\/code><\/td>\n<td>\u8a2d\u5b9a\u52d5\u756b<\/td>\n<td><code>animation: slide 2s infinite;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>@keyframes<\/code><\/td>\n<td>\u5b9a\u7fa9\u52d5\u756b\u95dc\u9375\u5e40<\/td>\n<td><code>@keyframes slide { 0% { left: 0; } 100% { left: 100px; } }<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<h2>12. <strong>\u5176\u4ed6\u6709\u7528\u5c6c\u6027<\/strong><\/h2>\n<table>\n<thead>\n<tr>\n<th>\u5c6c\u6027<\/th>\n<th>\u63cf\u8ff0<\/th>\n<th>\u7bc4\u4f8b<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td><code>opacity<\/code><\/td>\n<td>\u8a2d\u5b9a\u900f\u660e\u5ea6<\/td>\n<td><code>opacity: 0.5;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>cursor<\/code><\/td>\n<td>\u8a2d\u5b9a\u9f20\u6a19\u6307\u6a19\u6a23\u5f0f<\/td>\n<td><code>cursor: pointer;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>box-shadow<\/code><\/td>\n<td>\u8a2d\u5b9a\u76d2\u9670\u5f71<\/td>\n<td><code>box-shadow: 2px 2px 5px grey;<\/code><\/td>\n<\/tr>\n<tr>\n<td><code>text-shadow<\/code><\/td>\n<td>\u8a2d\u5b9a\u6587\u5b57\u9670\u5f71<\/td>\n<td><code>text-shadow: 1px 1px 3px black;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<hr \/>\n<p>\u9019\u4efd <strong>CSS Cheat Sheet<\/strong> \u6db5\u84cb\u4e86\u6700\u5e38\u898b\u548c\u57fa\u672c\u7684 CSS \u5c6c\u6027\u548c\u7528\u6cd5\uff0c\u8b93\u4f60\u80fd\u5920\u5feb\u901f\u53c3\u8003\u8207\u61c9\u7528\u3002\u9032\u968e\u90e8\u5206\u5982 <strong>Flexbox<\/strong> \u548c <strong>Grid<\/strong> \u4e5f\u662f\u73fe\u4ee3\u7db2\u9801\u8a2d\u8a08\u4e2d\u7684\u91cd\u8981\u4f48\u5c40\u5de5\u5177\uff0c\u503c\u5f97\u6df1\u5165\u5b78\u7fd2\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSS Cheat Sheet 1. CSS \u57fa\u672c\u8a9e\u6cd5 \u9078\u64c7\u5668 { \u5c6c\u6027: \u503c; &hellip; <\/p>\n","protected":false},"author":1,"featured_media":14977,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_import_markdown_pro_load_document_selector":0,"_import_markdown_pro_submit_text_textarea":"","fifu_image_url":"","fifu_image_alt":"","footnotes":""},"categories":[266],"tags":[],"class_list":["post-15013","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-266"],"_links":{"self":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/15013","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/comments?post=15013"}],"version-history":[{"count":2,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/15013\/revisions"}],"predecessor-version":[{"id":15017,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/posts\/15013\/revisions\/15017"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media\/14977"}],"wp:attachment":[{"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/media?parent=15013"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/categories?post=15013"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fgchen.com\/wpedu\/wp-json\/wp\/v2\/tags?post=15013"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}