{"id":1372,"date":"2025-02-06T23:38:38","date_gmt":"2025-02-06T15:38:38","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=1372"},"modified":"2025-02-06T23:38:39","modified_gmt":"2025-02-06T15:38:39","slug":"css-%e9%ab%98%e7%ba%a7%e6%8a%80%e5%b7%a7%ef%bc%9a%e5%8a%a8%e7%94%bb%e3%80%81%e8%bf%87%e6%b8%a1%e4%b8%8e%e5%8f%98%e6%8d%a2","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/02\/06\/css-%e9%ab%98%e7%ba%a7%e6%8a%80%e5%b7%a7%ef%bc%9a%e5%8a%a8%e7%94%bb%e3%80%81%e8%bf%87%e6%b8%a1%e4%b8%8e%e5%8f%98%e6%8d%a2\/","title":{"rendered":"CSS \u9ad8\u7ea7\u6280\u5de7\uff1a\u52a8\u753b\u3001\u8fc7\u6e21\u4e0e\u53d8\u6362"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u638c\u63e1 CSS \u9ad8\u7ea7\u6280\u5de7\uff0c\u80fd\u591f\u8ba9\u4f60\u5728\u7f51\u9875\u5f00\u53d1\u4e2d\u5b9e\u73b0\u66f4\u52a0\u4e30\u5bcc\u3001\u52a8\u6001\u548c\u4e92\u52a8\u6027\u5f3a\u7684\u6548\u679c\u3002\u8fd9\u4e9b\u6280\u672f\u4e3a\u524d\u7aef\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u4e86\u66f4\u9ad8\u7684\u8bbe\u8ba1\u81ea\u7531\u5ea6\u548c\u521b\u4f5c\u7a7a\u95f4\u3002\u8ba9\u6211\u4eec\u6df1\u5165\u4e86\u89e3\u4e00\u4e9b\u5e38\u7528\u7684 CSS \u9ad8\u7ea7\u6280\u5de7\uff0c\u5305\u62ec <strong>\u52a8\u753b\u4e0e\u8fc7\u6e21<\/strong>\u3001<strong>\u53d8\u6362<\/strong>\u3001<strong>\u81ea\u5b9a\u4e49\u5c5e\u6027\uff08CSS \u53d8\u91cf\uff09<\/strong> \u548c <strong>CSS \u51fd\u6570<\/strong>\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">1. \u52a8\u753b\u4e0e\u8fc7\u6e21<\/h4>\n\n\n\n<h5 class=\"wp-block-heading\">1.1 CSS \u8fc7\u6e21\uff08transition\uff09<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">CSS \u8fc7\u6e21\u662f\u5141\u8bb8\u5143\u7d20\u4ece\u4e00\u79cd\u6837\u5f0f\u5e73\u6ed1\u8fc7\u6e21\u5230\u53e6\u4e00\u79cd\u6837\u5f0f\u7684\u6548\u679c\u3002\u5b83\u4f7f\u5f97\u5143\u7d20\u7684\u53d8\u5316\u8fc7\u7a0b\u66f4\u52a0\u81ea\u7136\uff0c\u53ef\u4ee5\u7528\u4e8e\u8bb8\u591a\u4ea4\u4e92\u6548\u679c\u4e2d\uff0c\u5982\u9f20\u6807\u60ac\u505c\u3001\u70b9\u51fb\u7b49\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8bed\u6cd5\uff1a<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  selector {\n    property: value;\n    transition: property duration timing-function delay;\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>property<\/strong>\uff1a\u5b9a\u4e49\u8fc7\u6e21\u7684\u5c5e\u6027\uff0c\u5982 <code>color<\/code>, <code>background-color<\/code>\u3002<\/li>\n\n\n\n<li><strong>duration<\/strong>\uff1a\u8fc7\u6e21\u7684\u65f6\u95f4\uff0c\u5982 <code>0.3s<\/code>\u3002<\/li>\n\n\n\n<li><strong>timing-function<\/strong>\uff1a\u5b9a\u4e49\u8fc7\u6e21\u7684\u901f\u5ea6\u66f2\u7ebf\uff0c\u5e38\u7528\u7684\u6709 <code>ease<\/code>, <code>linear<\/code>, <code>ease-in<\/code>, <code>ease-out<\/code>\u3002<\/li>\n\n\n\n<li><strong>delay<\/strong>\uff1a\u8fc7\u6e21\u7684\u5ef6\u8fdf\u65f6\u95f4\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/* \u9ed8\u8ba4\u6837\u5f0f *\/\nbutton {\n  background-color: blue;\n  color: white;\n  transition: background-color 0.3s ease, transform 0.3s ease;\n}\n\n\/* \u9f20\u6807\u60ac\u505c\u65f6 *\/\nbutton:hover {\n  background-color: green;\n  transform: scale(1.1); \/* \u9f20\u6807\u60ac\u505c\u65f6\u653e\u5927 *\/\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u6309\u94ae\u7684\u80cc\u666f\u8272\u548c\u5927\u5c0f\u5c06\u5728\u9f20\u6807\u60ac\u505c\u65f6\u5e73\u6ed1\u8fc7\u6e21\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">1.2 CSS \u52a8\u753b\uff08@keyframes\uff09<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">CSS \u52a8\u753b\u901a\u8fc7 <code>@keyframes<\/code> \u89c4\u5219\u6765\u5b9a\u4e49\u4e00\u7cfb\u5217\u5173\u952e\u5e27\uff0c\u4f7f\u5143\u7d20\u7684\u72b6\u6001\u53d1\u751f\u9010\u6b65\u53d8\u5316\u3002\u6bd4\u8d77\u8fc7\u6e21\uff0c\u52a8\u753b\u63d0\u4f9b\u4e86\u66f4\u591a\u7684\u63a7\u5236\u548c\u590d\u6742\u7684\u6548\u679c\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u8bed\u6cd5\uff1a<\/strong><\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  @keyframes animation-name {\n    from {\n      property: value;\n    }\n    to {\n      property: value;\n    }\n  }\n\n  selector {\n    animation: animation-name duration timing-function delay iteration-count direction;\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>from<\/strong> \u548c <strong>to<\/strong>\uff1a\u5b9a\u4e49\u52a8\u753b\u7684\u8d77\u59cb\u548c\u7ed3\u675f\u72b6\u6001\uff0c\u53ef\u4ee5\u4f7f\u7528\u767e\u5206\u6bd4\u6765\u5b9a\u4e49\u591a\u4e2a\u5173\u952e\u5e27\u3002<\/li>\n\n\n\n<li><strong>iteration-count<\/strong>\uff1a\u52a8\u753b\u5faa\u73af\u7684\u6b21\u6570\uff0c<code>infinite<\/code> \u8868\u793a\u65e0\u9650\u5faa\u73af\u3002<\/li>\n\n\n\n<li><strong>direction<\/strong>\uff1a\u63a7\u5236\u52a8\u753b\u7684\u64ad\u653e\u65b9\u5411\uff0c\u5982 <code>normal<\/code>\u3001<code>reverse<\/code> \u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@keyframes bounce {\n  0% {\n    transform: translateY(0);\n  }\n  50% {\n    transform: translateY(-20px);\n  }\n  100% {\n    transform: translateY(0);\n  }\n}\n\n.element {\n  animation: bounce 1s ease-in-out infinite;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e2a\u4f8b\u5b50\u4f1a\u8ba9\u5143\u7d20\u4e0a\u4e0b\u8df3\u52a8\uff0c\u901a\u8fc7 <code>@keyframes<\/code> \u5b9a\u4e49\u4e86\u5143\u7d20\u7684\u8fd0\u52a8\u8f68\u8ff9\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">1.3 \u52a8\u753b\u5c5e\u6027\uff1aanimation \u548c animation-timing-function<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>animation<\/strong> \u5c5e\u6027\u53ef\u4ee5\u6307\u5b9a\u52a8\u753b\u7684\u540d\u79f0\u3001\u6301\u7eed\u65f6\u95f4\u3001\u5ef6\u8fdf\u7b49\uff0c\u63a7\u5236\u52a8\u753b\u7684\u5404\u9879\u5c5e\u6027\u3002\u901a\u8fc7 <strong>animation-timing-function<\/strong>\uff0c\u4f60\u53ef\u4ee5\u8bbe\u7f6e\u52a8\u753b\u7684\u8fdb\u5ea6\u66f2\u7ebf\uff0c\u4f7f\u5f97\u52a8\u753b\u7684\u901f\u5ea6\u5728\u4e0d\u540c\u9636\u6bb5\u53d8\u5316\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.element {\n  animation: move 3s ease-in-out;\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u52a8\u753b <code>move<\/code> \u5c06\u6301\u7eed 3 \u79d2\uff0c\u4f7f\u7528 <code>ease-in-out<\/code> \u8fdb\u5ea6\u66f2\u7ebf\uff08\u5373\u5f00\u59cb\u548c\u7ed3\u675f\u65f6\u8f83\u6162\uff0c\u4e2d\u95f4\u8f83\u5feb\uff09\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">2. \u53d8\u6362\uff08Transform\uff09<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">CSS <strong>\u53d8\u6362<\/strong>\u5c5e\u6027\u5141\u8bb8\u4f60\u5bf9\u5143\u7d20\u8fdb\u884c\u65cb\u8f6c\u3001\u7f29\u653e\u3001\u5e73\u79fb\u548c\u503e\u659c\u7b49\u6548\u679c\uff0c\u5e38\u7528\u4e8e\u52a8\u6001\u6548\u679c\u548c\u4ea4\u4e92\u8bbe\u8ba1\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">2.1 2D \u53d8\u6362<\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>rotate()<\/strong>\uff1a\u65cb\u8f6c\u5143\u7d20\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    transform: rotate(45deg); \/* \u65cb\u8f6c 45 \u5ea6 *\/\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>scale()<\/strong>\uff1a\u7f29\u653e\u5143\u7d20\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    transform: scale(1.5); \/* \u653e\u5927 1.5 \u500d *\/\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>translate()<\/strong>\uff1a\u5e73\u79fb\u5143\u7d20\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    transform: translate(50px, 100px); \/* \u6c34\u5e73\u5e73\u79fb 50px\uff0c\u5782\u76f4\u5e73\u79fb 100px *\/\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>skew()<\/strong>\uff1a\u503e\u659c\u5143\u7d20\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    transform: skew(20deg, 10deg); \/* \u6cbf X \u8f74\u503e\u659c 20 \u5ea6\uff0c\u6cbf Y \u8f74\u503e\u659c 10 \u5ea6 *\/\n  }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b 2D \u53d8\u6362\u5e38\u7528\u4e8e\u57fa\u672c\u7684\u52a8\u753b\u548c\u4ea4\u4e92\u6548\u679c\uff0c\u7ed9\u7528\u6237\u5e26\u6765\u52a8\u6001\u611f\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">2.2 3D \u53d8\u6362<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">CSS \u652f\u6301 <strong>3D \u53d8\u6362<\/strong>\uff0c\u4f7f\u5143\u7d20\u5448\u73b0\u7acb\u4f53\u6548\u679c\uff0c\u5982\u65cb\u8f6c\u3001\u900f\u89c6\u7b49\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>perspective()<\/strong>\uff1a\u8bbe\u7f6e 3D \u5143\u7d20\u7684\u900f\u89c6\u89c6\u8ddd\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    transform: perspective(500px) rotateY(45deg);\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>rotateX() \u548c rotateY()<\/strong>\uff1a\u7ed5 X \u8f74\u548c Y \u8f74\u65cb\u8f6c\u5143\u7d20\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    transform: rotateX(30deg) rotateY(30deg); \/* \u6cbf X \u548c Y \u8f74\u65cb\u8f6c *\/\n  }<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">3D \u53d8\u6362\u4f7f\u5f97\u7f51\u9875\u8bbe\u8ba1\u66f4\u5177\u6df1\u5ea6\u611f\uff0c\u5e38\u7528\u4e8e\u5361\u7247\u7ffb\u8f6c\u3001\u65cb\u8f6c\u52a8\u753b\u7b49\u6548\u679c\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">3. \u81ea\u5b9a\u4e49\u5c5e\u6027\uff08CSS \u53d8\u91cf\uff09<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">CSS \u53d8\u91cf\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u529f\u80fd\uff0c\u5141\u8bb8\u4f60\u5728\u6837\u5f0f\u8868\u4e2d\u521b\u5efa\u53ef\u91cd\u7528\u7684\u53d8\u91cf\uff0c\u4ece\u800c\u7b80\u5316\u4ee3\u7801\u7684\u7ef4\u62a4\u548c\u4fee\u6539\u3002\u4f7f\u7528 <code>--<\/code> \u5b9a\u4e49\u53d8\u91cf\uff0c\u5e76\u901a\u8fc7 <code>var()<\/code> \u5f15\u7528\u5b83\u4eec\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">3.1 \u4f7f\u7528 <code>--<\/code> \u5b9a\u4e49\u53d8\u91cf<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">CSS \u53d8\u91cf\u7684\u5b9a\u4e49\u901a\u5e38\u5728 <code>:root<\/code> \u9009\u62e9\u5668\u4e2d\uff0c\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u5168\u5c40\u53ef\u7528\uff0c\u4e5f\u53ef\u4ee5\u5728\u5c40\u90e8\u5143\u7d20\u4e2d\u5b9a\u4e49\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>:root {\n  --primary-color: #3498db;\n  --font-size: 16px;\n}\n\n.element {\n  color: var(--primary-color);\n  font-size: var(--font-size);\n}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">3.2 \u53d8\u91cf\u7684\u4f5c\u7528\u8303\u56f4\u4e0e\u7ee7\u627f<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">CSS \u53d8\u91cf\u7684\u4f5c\u7528\u8303\u56f4\u662f\u57fa\u4e8e DOM \u7ed3\u6784\u7684\uff0c\u5b50\u5143\u7d20\u53ef\u4ee5\u7ee7\u627f\u7236\u5143\u7d20\u5b9a\u4e49\u7684\u53d8\u91cf\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.container {\n  --container-color: red; \/* \u5728\u5bb9\u5668\u5185\u5b9a\u4e49 *\/\n}\n\n.container .item {\n  color: var(--container-color); \/* \u7ee7\u627f\u7236\u5143\u7d20\u7684\u53d8\u91cf *\/\n}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u4f7f\u7528 CSS \u53d8\u91cf\uff0c\u4f60\u53ef\u4ee5\u5728\u6574\u4e2a\u9875\u9762\u6216\u5e94\u7528\u4e2d\u52a8\u6001\u8c03\u6574\u4e3b\u9898\u6216\u6837\u5f0f\uff0c\u51cf\u5c11\u91cd\u590d\u4ee3\u7801\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">4. CSS \u51fd\u6570<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">CSS \u63d0\u4f9b\u4e86\u4e00\u4e9b\u5185\u7f6e\u7684\u51fd\u6570\u6765\u8fdb\u884c\u8ba1\u7b97\u548c\u7075\u6d3b\u7684\u6837\u5f0f\u64cd\u4f5c\uff0c\u589e\u5f3a\u4e86\u5e03\u5c40\u548c\u6837\u5f0f\u7684\u52a8\u6001\u6027\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\">4.1 <code>calc()<\/code> \u51fd\u6570<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\"><code>calc()<\/code> \u51fd\u6570\u53ef\u4ee5\u8ba9\u4f60\u5728 CSS \u4e2d\u8fdb\u884c\u7b80\u5355\u7684\u6570\u5b66\u8fd0\u7b97\uff0c\u901a\u5e38\u7528\u4e8e\u52a8\u6001\u8c03\u6574\u5bbd\u5ea6\u3001\u9ad8\u5ea6\u3001\u95f4\u8ddd\u7b49\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.element {\n  width: calc(100% - 20px); \/* \u5bbd\u5ea6\u4e3a\u7236\u5bb9\u5668\u7684 100% \u51cf\u53bb 20px *\/\n}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">4.2 <code>var()<\/code> \u51fd\u6570<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\"><code>var()<\/code> \u51fd\u6570\u7528\u4e8e\u5f15\u7528 CSS \u53d8\u91cf\u3002\u5b83\u4f7f\u5f97\u6837\u5f0f\u66f4\u52a0\u52a8\u6001\u548c\u7075\u6d3b\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>.element {\n  background-color: var(--primary-color);\n  font-size: calc(var(--font-size) * 1.2); \/* \u52a8\u6001\u8ba1\u7b97\u5b57\u4f53\u5927\u5c0f *\/\n}<\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\">4.3 <code>min()<\/code>, <code>max()<\/code>, <code>clamp()<\/code> \u51fd\u6570<\/h5>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u51fd\u6570\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5728\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u4e2d\u7075\u6d3b\u8c03\u6574\u5c5e\u6027\u503c\uff0c\u786e\u4fdd\u5143\u7d20\u7684\u5c3a\u5bf8\u548c\u5b57\u4f53\u5927\u5c0f\u9002\u5e94\u4e0d\u540c\u7684\u5c4f\u5e55\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>min()<\/code><\/strong>\uff1a\u8fd4\u56de\u6700\u5c0f\u503c\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    width: min(50%, 400px); \/* \u5bbd\u5ea6\u4e3a 50% \u548c 400px \u4e2d\u7684\u6700\u5c0f\u503c *\/\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>max()<\/code><\/strong>\uff1a\u8fd4\u56de\u6700\u5927\u503c\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    width: max(50%, 200px); \/* \u5bbd\u5ea6\u4e3a 50% \u548c 200px \u4e2d\u7684\u6700\u5927\u503c *\/\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>clamp()<\/code><\/strong>\uff1a\u6839\u636e\u7ed9\u5b9a\u8303\u56f4\u8ba1\u7b97\u4e00\u4e2a\u503c\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    font-size: clamp(16px, 5vw, 24px); \/* \u5b57\u4f53\u5927\u5c0f\u5728 16px \u548c 24px \u4e4b\u95f4\uff0c\u968f\u7740\u89c6\u53e3\u5bbd\u5ea6\u53d8\u5316 *\/\n  }<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u5c0f\u7ed3<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u638c\u63e1\u8fd9\u4e9b <strong>CSS \u9ad8\u7ea7\u6280\u5de7<\/strong>\uff0c\u4f60\u80fd\u591f\u521b\u5efa\u66f4\u5177\u4e92\u52a8\u6027\u3001\u52a8\u6001\u6548\u679c\u7684\u7f51\u9875\u8bbe\u8ba1\uff0c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\u3002\u8fd9\u4e9b\u6280\u5de7\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u4f60\u5b9e\u73b0\u52a8\u753b\u548c\u53d8\u6362\u6548\u679c\uff0c\u8fd8\u80fd\u63d0\u5347\u6837\u5f0f\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u7075\u6d3b\u6027\u3002\u65e0\u8bba\u662f\u901a\u8fc7 <strong>CSS \u53d8\u91cf<\/strong> \u6765\u7b80\u5316\u4e3b\u9898\u5207\u6362\uff0c\u8fd8\u662f\u4f7f\u7528 <strong>CSS \u51fd\u6570<\/strong> \u6765\u52a8\u6001\u8c03\u6574\u5e03\u5c40\uff0c\u638c\u63e1\u8fd9\u4e9b\u9ad8\u7ea7\u6280\u5de7\u5c06\u4f7f\u4f60\u6210\u4e3a\u66f4\u51fa\u8272\u7684\u524d\u7aef\u5f00\u53d1\u8005\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p class=\"wp-block-paragraph\">CSS \u9ad8\u7ea7\u6280\u5de7\u4e3a\u5f00\u53d1\u8005\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u521b\u5efa\u66f4\u5177\u4e92\u52a8\u6027\u548c\u52a8\u6001\u6548\u679c\u7684\u7f51\u9875\u3002\u901a\u8fc7 <strong>\u52a8\u753b\u4e0e\u8fc7\u6e21<\/strong>\u3001<strong>\u53d8\u6362<\/strong>\u3001<strong>\u81ea\u5b9a\u4e49\u5c5e\u6027<\/strong> \u548c <strong>CSS \u51fd\u6570<\/strong> \u7684\u5408\u7406\u5e94\u7528\uff0c\u7f51\u9875\u8bbe\u8ba1\u4e0d\u4ec5\u80fd\u66f4\u52a0\u7075\u6d3b\u3001\u54cd\u5e94\u5f0f\uff0c\u8fd8\u80fd\u5e26\u6765\u66f4\u4e30\u5bcc\u7684\u89c6\u89c9\u6548\u679c\u548c\u66f4\u9ad8\u7684\u6027\u80fd\u4f18\u5316\u3002\u4e0b\u9762\u603b\u7ed3\u4e00\u4e0b\u5e38\u7528\u7684\u5e94\u7528\u573a\u666f\u548c\u6280\u5de7\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. \u52a8\u753b\u4e0e\u8fc7\u6e21\u7684\u5e94\u7528<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u6309\u94ae\u548c\u94fe\u63a5\u7684\u4e92\u52a8\u6548\u679c<\/strong>\uff1a\u4f7f\u7528\u8fc7\u6e21\u548c\u52a8\u753b\u53ef\u4ee5\u4f7f\u6309\u94ae\u5728\u60ac\u505c\u65f6\u4ea7\u751f\u989c\u8272\u53d8\u5316\u3001\u9634\u5f71\u6548\u679c\uff0c\u751a\u81f3\u662f\u5f62\u72b6\u7684\u53d8\u5316\uff0c\u589e\u5f3a\u7528\u6237\u7684\u4ea4\u4e92\u4f53\u9a8c\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  button {\n    background-color: blue;\n    color: white;\n    padding: 10px 20px;\n    border-radius: 5px;\n    transition: background-color 0.3s ease, transform 0.3s ease;\n  }\n\n  button:hover {\n    background-color: green;\n    transform: scale(1.1); \/* \u9f20\u6807\u60ac\u505c\u65f6\u653e\u5927 *\/\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5185\u5bb9\u52a0\u8f7d\u52a8\u753b<\/strong>\uff1a\u901a\u8fc7\u52a8\u753b\u53ef\u4ee5\u8ba9\u9875\u9762\u52a0\u8f7d\u65f6\u5448\u73b0\u51fa\u5e73\u6ed1\u7684\u6548\u679c\uff0c\u4f8b\u5982\u9010\u6e10\u663e\u73b0\u3001\u65cb\u8f6c\u52a0\u8f7d\u6761\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  @keyframes fadeIn {\n    0% {\n      opacity: 0;\n    }\n    100% {\n      opacity: 1;\n    }\n  }\n\n  .loading {\n    animation: fadeIn 2s ease-in-out;\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u5361\u7247\u7ffb\u8f6c\u6548\u679c<\/strong>\uff1aCSS 3D \u53d8\u6362\u53ef\u4ee5\u5b9e\u73b0\u7c7b\u4f3c\u5361\u7247\u7ffb\u8f6c\u7684\u6548\u679c\uff0c\u8fd9\u5728\u4ea7\u54c1\u5c55\u793a\u3001\u4e92\u52a8\u754c\u9762\u7b49\u573a\u666f\u4e2d\u975e\u5e38\u5e38\u89c1\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .card {\n    width: 200px;\n    height: 300px;\n    perspective: 1000px; \/* \u6dfb\u52a0\u900f\u89c6\u6548\u679c *\/\n  }\n\n  .card-inner {\n    transform-style: preserve-3d;\n    transition: transform 1s;\n  }\n\n  .card:hover .card-inner {\n    transform: rotateY(180deg); \/* \u9f20\u6807\u60ac\u505c\u65f6\u7ffb\u8f6c *\/\n  }<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. \u53d8\u6362\u7684\u5e94\u7528<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u65cb\u8f6c\u548c\u7f29\u653e<\/strong>\uff1a\u65cb\u8f6c\u548c\u7f29\u653e\u662f\u7f51\u9875\u52a8\u753b\u548c\u6548\u679c\u4e2d\u975e\u5e38\u5e38\u89c1\u7684\u6280\u672f\uff0c\u53ef\u4ee5\u7528\u4e8e\u6309\u94ae\u3001\u56fe\u6807\u6216\u5176\u4ed6\u5143\u7d20\u7684\u89c6\u89c9\u53cd\u9988\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .icon {\n    transform: rotate(45deg); \/* \u65cb\u8f6c 45 \u5ea6 *\/\n  }\n\n  .zoom {\n    transform: scale(1.5); \/* \u653e\u5927 1.5 \u500d *\/\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u79fb\u52a8\u5143\u7d20<\/strong>\uff1a\u901a\u8fc7\u5e73\u79fb\uff0c\u53ef\u4ee5\u5c06\u5143\u7d20\u4ece\u4e00\u4e2a\u4f4d\u7f6e\u79fb\u52a8\u5230\u53e6\u4e00\u4e2a\u4f4d\u7f6e\uff0c\u5e38\u7528\u4e8e\u6a21\u6001\u6846\u7684\u51fa\u73b0\u3001\u4e0b\u62c9\u83dc\u5355\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .popup {\n    transform: translateY(-100%); \/* \u9ed8\u8ba4\u9690\u85cf *\/\n    transition: transform 0.3s ease-in-out;\n  }\n\n  .popup.open {\n    transform: translateY(0); \/* \u6253\u5f00\u65f6\uff0c\u79fb\u52a8\u5230\u663e\u793a\u4f4d\u7f6e *\/\n  }<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">7. \u81ea\u5b9a\u4e49\u5c5e\u6027\uff08CSS \u53d8\u91cf\uff09\u7684\u5e94\u7528<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u4e3b\u9898\u5207\u6362<\/strong>\uff1a\u4f7f\u7528 CSS \u53d8\u91cf\u53ef\u4ee5\u8f7b\u677e\u5b9e\u73b0\u7f51\u7ad9\u4e3b\u9898\u5207\u6362\uff0c\u6539\u53d8\u989c\u8272\u3001\u5b57\u4f53\u7b49\u6837\u5f0f\uff0c\u800c\u65e0\u9700\u4fee\u6539\u591a\u4e2a\u5730\u65b9\u7684 CSS \u4ee3\u7801\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  :root {\n    --background-color: white;\n    --text-color: black;\n  }\n\n  .dark-theme {\n    --background-color: #333;\n    --text-color: #fff;\n  }\n\n  body {\n    background-color: var(--background-color);\n    color: var(--text-color);\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u52a8\u6001\u8c03\u6574\u5e03\u5c40<\/strong>\uff1a\u901a\u8fc7\u4f7f\u7528 CSS \u53d8\u91cf\uff0c\u4f60\u53ef\u4ee5\u5728\u6574\u4e2a\u6587\u6863\u4e2d\u52a8\u6001\u8c03\u6574\u5e03\u5c40\uff0c\u6539\u53d8\u5b57\u4f53\u5927\u5c0f\u3001\u5143\u7d20\u95f4\u8ddd\u7b49\uff0c\u800c\u65e0\u9700\u6bcf\u6b21\u90fd\u91cd\u5199\u6837\u5f0f\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  :root {\n    --font-size: 16px;\n  }\n\n  body {\n    font-size: var(--font-size);\n  }\n\n  .container {\n    padding: calc(var(--font-size) * 2); \/* \u52a8\u6001\u8c03\u6574\u5bb9\u5668\u5185\u8fb9\u8ddd *\/\n  }<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">8. CSS \u51fd\u6570\u7684\u5e94\u7528<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>calc()<\/code> \u51fd\u6570<\/strong>\uff1a\u9002\u7528\u4e8e\u9700\u8981\u52a8\u6001\u8ba1\u7b97\u5bbd\u5ea6\u3001\u95f4\u8ddd\u7b49\u573a\u5408\uff0c\u5c24\u5176\u5728\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u4e2d\u5341\u5206\u6709\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .container {\n    width: calc(100% - 40px); \/* \u5bb9\u5668\u5bbd\u5ea6\u51cf\u53bb 40px *\/\n  }<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong><code>min()<\/code>, <code>max()<\/code> \u548c <code>clamp()<\/code><\/strong>\uff1a\u8fd9\u51e0\u4e2a\u51fd\u6570\u7279\u522b\u9002\u5408\u5728\u54cd\u5e94\u5f0f\u5e03\u5c40\u4e2d\u4f7f\u7528\uff0c\u53ef\u4ee5\u786e\u4fdd\u5143\u7d20\u7684\u5927\u5c0f\u5728\u4e00\u5b9a\u8303\u56f4\u5185\u81ea\u9002\u5e94\u3002<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>  .element {\n    width: min(50%, 400px); \/* \u5bbd\u5ea6\u6700\u5927\u4e3a 400px\uff0c\u4f46\u4e0d\u80fd\u8d85\u8fc7\u7236\u5143\u7d20\u7684 50% *\/\n    font-size: clamp(16px, 5vw, 24px); \/* \u5b57\u4f53\u5927\u5c0f\u6839\u636e\u89c6\u53e3\u5bbd\u5ea6\u52a8\u6001\u53d8\u5316 *\/\n  }<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u603b\u7ed3<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u901a\u8fc7\u4f7f\u7528\u8fd9\u4e9b <strong>CSS \u9ad8\u7ea7\u6280\u5de7<\/strong>\uff0c\u4f60\u53ef\u4ee5\u5b9e\u73b0\u66f4\u7cbe\u7f8e\u3001\u54cd\u5e94\u5f0f\u4e14\u4ea4\u4e92\u6027\u5f3a\u7684\u7f51\u9875\u8bbe\u8ba1\u3002\u65e0\u8bba\u662f <strong>\u8fc7\u6e21\u548c\u52a8\u753b<\/strong>\u3001<strong>\u53d8\u6362<\/strong>\u3001<strong>CSS \u53d8\u91cf<\/strong> \u8fd8\u662f <strong>CSS \u51fd\u6570<\/strong>\uff0c\u5b83\u4eec\u4e0d\u4ec5\u80fd\u589e\u5f3a\u89c6\u89c9\u6548\u679c\uff0c\u8fd8\u80fd\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u7ef4\u62a4\u6027\u548c\u6027\u80fd\u3002\u638c\u63e1\u8fd9\u4e9b\u6280\u5de7\u540e\uff0c\u4f60\u53ef\u4ee5\u5728\u524d\u7aef\u5f00\u53d1\u4e2d\u5904\u7406\u66f4\u590d\u6742\u7684\u573a\u666f\u548c\u9700\u6c42\uff0c\u63d0\u5347\u7528\u6237\u4f53\u9a8c\uff0c\u8ba9\u4f60\u7684\u7f51\u9875\u5728\u89c6\u89c9\u548c\u4ea4\u4e92\u4e0a\u66f4\u52a0\u51fa\u8272\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u4e9b\u6280\u672f\u4e0d\u4ec5\u80fd\u5e2e\u52a9\u4f60\u5728\u65e5\u5e38\u5f00\u53d1\u4e2d\u521b\u9020\u51fa\u8272\u7684\u7f51\u9875\u6548\u679c\uff0c\u8fd8\u80fd\u8ba9\u4f60\u66f4\u52a0\u9ad8\u6548\u5730\u7ba1\u7406\u548c\u8c03\u6574\u7f51\u7ad9\u7684\u6837\u5f0f\uff0c\u9002\u5e94\u4e0d\u540c\u5c4f\u5e55\u548c\u8bbe\u5907\uff0c\u6253\u9020\u73b0\u4ee3\u5316\u7684\u3001\u7b26\u5408\u9700\u6c42\u7684\u7f51\u9875\u8bbe\u8ba1\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u638c\u63e1 CSS \u9ad8\u7ea7\u6280\u5de7\uff0c\u80fd\u591f\u8ba9\u4f60\u5728\u7f51\u9875\u5f00\u53d1\u4e2d\u5b9e\u73b0\u66f4\u52a0\u4e30\u5bcc\u3001\u52a8\u6001\u548c\u4e92\u52a8\u6027\u5f3a\u7684\u6548\u679c\u3002\u8fd9\u4e9b\u6280\u672f\u4e3a\u524d\u7aef\u5f00\u53d1\u4eba\u5458\u63d0\u4f9b\u4e86\u66f4 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[],"class_list":["post-1372","post","type-post","status-publish","format-standard","hentry","category-css"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1372","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=1372"}],"version-history":[{"count":2,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1372\/revisions"}],"predecessor-version":[{"id":1383,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1372\/revisions\/1383"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=1372"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=1372"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=1372"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}