{"id":261851,"date":"2024-05-15T14:16:15","date_gmt":"2024-05-15T06:16:15","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/261851.html"},"modified":"2024-05-15T14:16:25","modified_gmt":"2024-05-15T06:16:25","slug":"%e5%a6%82%e4%bd%95%e5%86%99%e4%b8%80%e6%ae%b5php%e4%bb%a3%e7%a0%81%e6%8a%8ahtml%e5%ad%97%e7%ac%a6%e4%b8%b2%e8%bd%ac%e6%88%90%e5%9b%be%e7%89%87%e5%b9%b6%e4%bf%9d%e7%95%99css%e6%a0%b7%e5%bc%8f-2","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/261851.html","title":{"rendered":"\u5982\u4f55\u5199\u4e00\u6bb5php\u4ee3\u7801\u628ahtml\u5b57\u7b26\u4e32\u8f6c\u6210\u56fe\u7247\u5e76\u4fdd\u7559css\u6837\u5f0f"},"content":{"rendered":"<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/27121348\/d3f8bba6-e935-43ea-beee-a1e1cd954031.webp\" alt=\"\u5982\u4f55\u5199\u4e00\u6bb5php\u4ee3\u7801\u628ahtml\u5b57\u7b26\u4e32\u8f6c\u6210\u56fe\u7247\u5e76\u4fdd\u7559css\u6837\u5f0f\" \/><\/p>\n<p><p>\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u56fe\u7247\u5e76\u4fdd\u7559CSS\u6837\u5f0f\u662f\u4e00\u4e2a\u5728Web\u5f00\u53d1\u4e2d\u5e38\u9047\u5230\u7684\u95ee\u9898\uff0c\u5c24\u5176\u662f\u5728\u9700\u8981\u5c06Web\u9875\u9762\u6216\u5176\u90e8\u5206\u5185\u5bb9\u5bfc\u51fa\u4e3a\u56fe\u50cf\u683c\u5f0f\u4ee5\u4fbf\u4e8e\u5206\u4eab\u6216\u5b58\u6863\u65f6\u3002\u89e3\u51b3\u8fd9\u4e00\u95ee\u9898\u7684\u65b9\u6cd5\u5206\u4e3a\u51e0\u4e2a\u6b65\u9aa4\uff1a<strong>\u4f7f\u7528PHP\u811a\u672c\u6355\u83b7HTML\u5185\u5bb9\u3001\u5e94\u7528CSS\u6837\u5f0f\u3001\u6700\u540e\u751f\u6210\u56fe\u7247<\/strong>\u3002\u5728\u8fd9\u4e00\u8fc7\u7a0b\u4e2d\uff0c\u6211\u4eec\u4e3b\u8981\u4f9d\u8d56<strong>PHP\u7684GD\u5e93<\/strong>\u6216\u4f7f\u7528<strong>\u989d\u5916\u7684\u5e93\u50cfwkhtmltopdf<\/strong>\u8fd9\u7c7b\u5de5\u5177\u3002\u5176\u4e2d\uff0c\u4f7f\u7528GD\u5e93\u662f\u8f83\u4e3a\u57fa\u7840\u4e14\u76f4\u63a5\u7684\u65b9\u5f0f\uff0c\u4f46\u4e3a\u4e86\u5b9e\u73b0\u590d\u6742\u7684\u5e03\u5c40\u548c\u6837\u5f0f\u652f\u6301\uff0c\u53ef\u80fd\u9700\u8981\u501f\u52a9\u5916\u90e8\u5e93\u6216\u5de5\u5177\u3002<\/p>\n<\/p>\n<p><h3>\u4e00\u3001\u7406\u89e3\u57fa\u7840\u6982\u5ff5<\/h3>\n<\/p>\n<p><p><strong>PHP\u7684GD\u5e93<\/strong>\u662f\u7528\u4e8e\u52a8\u6001\u751f\u6210\u56fe\u7247\u7684\u4e00\u5957API\uff0c\u652f\u6301\u591a\u79cd\u56fe\u7247\u683c\u5f0f\uff0c\u5e76\u5141\u8bb8\u8fdb\u884c\u56fe\u7247\u5904\u7406\u3001\u6587\u5b57\u6dfb\u52a0\u7b49\u64cd\u4f5c\u3002\u7136\u800c\uff0cGD\u5e93\u672c\u8eab\u4e0d\u89e3\u6790CSS\u6837\u5f0f\uff0c\u56e0\u6b64\u76f4\u63a5\u5c06HTML+CSS\u8f6c\u6362\u4e3a\u56fe\u7247\u65f6\uff0c\u9700\u8981\u989d\u5916\u5904\u7406CSS\u6837\u5f0f\uff0c\u786e\u4fdd\u6700\u7ec8\u751f\u6210\u7684\u56fe\u7247\u4fdd\u7559\u4e86HTML\u5185\u5bb9\u7684\u5916\u89c2\u3002<\/p>\n<\/p>\n<p><p><strong>wkhtmltopdf\u548c\u76f8\u5173\u5de5\u5177<\/strong>\uff08\u5982wkhtmltoimage\uff09\u80cc\u540e\u4f7f\u7528WebKit\u5e03\u5c40\u5f15\u64ce\uff08\u540cChrome\u548cSafari\u4f7f\u7528\u7684\u5f15\u64ce\uff09\uff0c\u80fd\u8f83\u597d\u5730\u5904\u7406\u590d\u6742\u7684HTML\u548cCSS\uff0c\u5c06\u5176\u8f6c\u6362\u4e3aPDF\u6216\u56fe\u7247\u3002\u8fd9\u7c7b\u5de5\u5177\u80fd\u66f4\u51c6\u786e\u5730\u4fdd\u6301\u7f51\u9875\u7684\u6837\u5f0f\u548c\u5e03\u5c40\uff0c\u662f\u5904\u7406\u8f83\u590d\u6742\u9875\u9762\u8f6c\u56fe\u7247\u9700\u6c42\u7684\u597d\u9009\u62e9\u3002<\/p>\n<\/p>\n<p><h3>\u4e8c\u3001\u4f7f\u7528PHP GD\u5e93\u5b9e\u73b0\u57fa\u7840\u8f6c\u6362<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5\u4e0e\u914d\u7f6eGD\u5e93<\/strong><\/p>\n<\/p>\n<p><p>\u786e\u4fddPHP\u73af\u5883\u5df2\u7ecf\u5b89\u88c5\u5e76\u542f\u7528GD\u5e93\u3002\u5728php.ini\u6587\u4ef6\u4e2d\u67e5\u627e\u5e76\u53d6\u6d88\u6ce8\u91caextension=gd\uff08\u53bb\u9664\u524d\u9762\u7684\u201c;\u201d\uff09\uff0c\u7136\u540e\u91cd\u65b0\u542f\u52a8PHP\u670d\u52a1\uff0c\u786e\u8ba4GD\u5e93\u53ef\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u5199\u4ee3\u7801\u5b9e\u73b0\u8f6c\u6362<\/strong><\/p>\n<\/p>\n<p><p>\u4f7f\u7528GD\u5e93\u521b\u5efa\u56fe\u7247\u901a\u5e38\u9996\u5148\u521b\u5efa\u4e00\u4e2a\u753b\u5e03\uff0c\u7136\u540e\u5728\u753b\u5e03\u4e0a\u7ed8\u5236\u5185\u5bb9\u3002\u5728HTML\u8f6c\u56fe\u7247\u7684\u573a\u666f\u4e0b\uff0c\u53ef\u80fd\u9700\u8981\u9996\u5148\u4f7f\u7528PHP\u7684\u8f93\u51fa\u7f13\u5b58\u529f\u80fd\u6355\u83b7HTML\u8f93\u51fa\uff0c\u7136\u540e\u89e3\u6790HTML\u5185\u5bb9\uff0c\u6700\u7ec8\u5c06\u5176\u7ed8\u5236\u5230\u56fe\u50cf\u4e0a\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u4e09\u3001\u5229\u7528\u5916\u90e8\u5de5\u5177\u5b9e\u73b0\u9ad8\u7ea7\u8f6c\u6362<\/h3>\n<\/p>\n<ol>\n<li>\n<p><strong>\u5b89\u88c5wkhtmltoimage<\/strong><\/p>\n<\/p>\n<p><p>wkhtmltopdf\u53ca\u5176\u56fe\u50cf\u7248\u672cwkhtmltoimage\u53ef\u4ee5\u901a\u8fc7\u5176\u5b98\u7f51\u4e0b\u8f7d\u5e76\u5b89\u88c5\u3002\u8fd9\u4e24\u6b3e\u5de5\u5177\u90fd\u63d0\u4f9b\u547d\u4ee4\u884c\u754c\u9762\uff0c\u53ef\u4ee5\u901a\u8fc7PHP\u7684<code>exec()<\/code>\u51fd\u6570\u8c03\u7528\u3002<\/p>\n<\/p>\n<\/li>\n<li>\n<p><strong>\u7f16\u5199\u8f6c\u6362\u811a\u672c<\/strong><\/p>\n<\/p>\n<p><p>\u5229\u7528wkhtmltoimage\uff0c\u53ef\u4ee5\u76f4\u63a5\u5c06\u4e00\u4e2aHTML\u6587\u4ef6\u6216HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u56fe\u7247\uff0c\u540c\u65f6\u4fdd\u7559CSS\u6837\u5f0f\u3002\u8fd9\u4e00\u8fc7\u7a0b\u7b80\u5355\u9ad8\u6548\uff0c\u901a\u8fc7\u547d\u4ee4\u884c\u53c2\u6570\u53ef\u4ee5\u8c03\u6574\u8f93\u51fa\u56fe\u7247\u7684\u5927\u5c0f\u3001\u8d28\u91cf\u7b49\u3002<\/p>\n<\/p>\n<\/li>\n<\/ol>\n<p><h3>\u56db\u3001\u793a\u4f8b\u4ee3\u7801\u548c\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p>\u4e0b\u9762\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u7684\u793a\u4f8b\uff0c\u5c55\u73b0\u5982\u4f55\u4f7f\u7528PHP\u548cwkhtmltoimage\u5de5\u5177\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u56fe\u7247\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-php\">&lt;?php<\/p>\n<p>$htmlContent = &#039;&lt;!DOCTYPE html&gt;<\/p>\n<p>&lt;html&gt;<\/p>\n<p>&lt;head&gt;<\/p>\n<p>    &lt;title&gt;Sample Page&lt;\/title&gt;<\/p>\n<p>    &lt;style&gt;body { color: red; }&lt;\/style&gt;<\/p>\n<p>&lt;\/head&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>    &lt;p&gt;Hello, World!&lt;\/p&gt;<\/p>\n<p>&lt;\/body&gt;<\/p>\n<p>&lt;\/html&gt;&#039;;<\/p>\n<p>\/\/ \u4fdd\u5b58HTML\u5185\u5bb9\u5230\u4e34\u65f6\u6587\u4ef6<\/p>\n<p>$tmpHtmlFile = &#039;temp.html&#039;;<\/p>\n<p>file_put_contents($tmpHtmlFile, $htmlContent);<\/p>\n<p>\/\/ \u6307\u5b9a\u8f93\u51fa\u56fe\u7247\u6587\u4ef6\u8def\u5f84<\/p>\n<p>$outputImageFile = &#039;output.png&#039;;<\/p>\n<p>\/\/ \u4f7f\u7528wkhtmltoimage\u547d\u4ee4\u884c\u5de5\u5177\u8fdb\u884c\u8f6c\u6362<\/p>\n<p>$cmd = &quot;wkhtmltoimage --quality 100 $tmpHtmlFile $outputImageFile&quot;;<\/p>\n<p>exec($cmd);<\/p>\n<p>\/\/ \u6e05\u7406\u4e34\u65f6\u6587\u4ef6<\/p>\n<p>unlink($tmpHtmlFile);<\/p>\n<p>\/\/ \u663e\u793a\u8f6c\u6362\u7ed3\u679c<\/p>\n<p>echo &#039;&lt;img src=&quot;&#039; . $outputImageFile . &#039;&quot; \/&gt;&#039;;<\/p>\n<p>?&gt;<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u4e94\u3001\u603b\u7ed3\u548c\u6700\u4f73\u5b9e\u8df5<\/h3>\n<\/p>\n<p><p>\u8f6c\u6362HTML\u5b57\u7b26\u4e32\u4e3a\u56fe\u7247\u5e76\u4fdd\u7559CSS\u6837\u5f0f\u662f\u4e00\u4e2a\u6d89\u53ca\u591a\u4e2a\u6b65\u9aa4\u7684\u590d\u6742\u8fc7\u7a0b\u3002<strong>\u4f7f\u7528PHP\u7684GD\u5e93\u53ef\u4ee5\u6267\u884c\u57fa\u7840\u7684\u8f6c\u6362<\/strong>\uff0c\u4f46\u5bf9\u4e8e\u590d\u6742\u7684\u5e03\u5c40\u548c\u6837\u5f0f\uff0c<strong>\u5229\u7528wkhtmltopdf\u548cwkhtmltoimage\u5c06\u63d0\u4f9b\u66f4\u597d\u7684\u652f\u6301<\/strong>\u3002\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u6839\u636e\u8f6c\u6362\u5185\u5bb9\u7684\u590d\u6742\u7a0b\u5ea6\u548c\u51c6\u786e\u6027\u8981\u6c42\u9009\u62e9\u5408\u9002\u7684\u5de5\u5177\u548c\u65b9\u6cd5\u6781\u5176\u91cd\u8981\u3002\u65e0\u8bba\u9009\u62e9\u54ea\u79cd\u65b9\u6848\uff0c\u90fd\u5e94\u8be5\u6ce8\u610f\u6027\u80fd\u4f18\u5316\u548c\u9519\u8bef\u5904\u7406\uff0c\u4ee5\u786e\u4fdd\u9ad8\u6548\u4e14\u7a33\u5b9a\u5730\u751f\u6210\u6700\u7ec8\u7684\u56fe\u7247\u6587\u4ef6\u3002<\/p>\n<\/p>\n<p><p>\u8ffd\u6c42\u9ad8\u8d28\u91cf\u7684\u8f6c\u6362\u7ed3\u679c\u65f6\uff0c\u4e0d\u8981\u5fd8\u8bb0\u5bf9\u751f\u6210\u7684\u56fe\u7247\u8fdb\u884c\u540e\u5904\u7406\uff0c\u5982\u8c03\u6574\u5927\u5c0f\u3001\u5e94\u7528\u538b\u7f29\u7b49\uff0c\u8fd9\u4e9b\u90fd\u6709\u52a9\u4e8e\u63d0\u9ad8\u9875\u9762\u52a0\u8f7d\u901f\u5ea6\u548c\u4f18\u5316\u7528\u6237\u4f53\u9a8c\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p><strong>1. \u5982\u4f55\u4f7f\u7528PHP\u4ee3\u7801\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u56fe\u7247\u5e76\u4fdd\u7559CSS\u6837\u5f0f\uff1f<\/strong><\/p>\n<p>\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u56fe\u7247\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u9700\u6c42\uff0c\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u5b9e\u73b0\uff1a<\/p>\n<p>a. \u9996\u5148\uff0c\u4f60\u9700\u8981\u4f7f\u7528PHP\u7684DOMDocument\u7c7b\u5c06HTML\u5b57\u7b26\u4e32\u52a0\u8f7d\u5230DOM\u5bf9\u8c61\u4e2d\u3002\u8fd9\u6837\u53ef\u4ee5\u4f7f\u4f60\u66f4\u5bb9\u6613\u5730\u64cd\u4f5cHTML\u7684\u5143\u7d20\u548c\u5c5e\u6027\u3002<\/p>\n<p>b. \u63a5\u4e0b\u6765\uff0c\u4f60\u53ef\u4ee5\u4f7f\u7528PHP\u7684GD\u5e93\u6216\u5176\u4ed6\u56fe\u50cf\u5904\u7406\u5e93\uff08\u5982Imagick\uff09\u5c06DOM\u5bf9\u8c61\u6e32\u67d3\u4e3a\u56fe\u50cf\u3002\u8fd9\u4e9b\u5e93\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\u6765\u521b\u5efa\u7a7a\u767d\u56fe\u50cf\uff0c\u5e76\u5c06HTML\u5143\u7d20\u53ca\u5176\u6837\u5f0f\u5e94\u7528\u5230\u56fe\u50cf\u4e0a\u3002<\/p>\n<p>c. \u5728\u6e32\u67d3\u56fe\u50cf\u4e4b\u524d\uff0c\u786e\u4fdd\u5728HTML\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u7684\u6240\u6709\u5916\u90e8CSS\u6587\u4ef6\uff08\u5982\u6837\u5f0f\u8868\u94fe\u63a5\uff09\u90fd\u80fd\u88ab\u6b63\u786e\u52a0\u8f7d\u3002\u4f60\u53ef\u80fd\u9700\u8981\u4f7f\u7528CSS\u89e3\u6790\u5668\u5e93\u6765\u89e3\u6790\u8fd9\u4e9b\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u5e94\u7528\u5230DOM\u5bf9\u8c61\u4e2d\u7684\u5143\u7d20\u4e0a\u3002<\/p>\n<p>d. \u6700\u540e\uff0c\u4f7f\u7528GD\u5e93\u6216Imagick\u5c06\u6e32\u67d3\u540e\u7684\u56fe\u50cf\u4fdd\u5b58\u5230\u6307\u5b9a\u7684\u76ee\u6807\u6587\u4ef6\u4e2d\u3002\u4f60\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u56fe\u50cf\u7684\u683c\u5f0f\u3001\u8d28\u91cf\u548c\u5c3a\u5bf8\u7b49\u53c2\u6570\u6765\u8c03\u6574\u6700\u7ec8\u751f\u6210\u7684\u56fe\u50cf\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u8bf7\u786e\u4fdd\u670d\u52a1\u5668\u4e0a\u5df2\u5b89\u88c5GD\u5e93\u6216Imagick\u6269\u5c55\uff0c\u5e76\u5141\u8bb8PHP\u811a\u672c\u6267\u884c\u56fe\u50cf\u5904\u7406\u64cd\u4f5c\u3002<\/p>\n<p><strong>2. \u662f\u5426\u6709\u73b0\u6210\u7684PHP\u5e93\u53ef\u4ee5\u5c06\u5e26\u6709CSS\u6837\u5f0f\u7684HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u56fe\u7247\uff1f<\/strong><\/p>\n<p>\u662f\u7684\uff0cPHP\u4e2d\u6709\u4e00\u4e9b\u5e93\u53ef\u4ee5\u5e2e\u52a9\u4f60\u5c06\u5e26\u6709CSS\u6837\u5f0f\u7684HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u56fe\u7247\u3002\u4ee5\u4e0b\u662f\u5176\u4e2d\u4e00\u4e9b\u5e38\u7528\u7684\u5e93\uff1a<\/p>\n<p>a. PHP GD\u5e93\uff1aGD\u5e93\u662f\u4e00\u79cd\u5e38\u89c1\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e00\u4e9b\u65b9\u6cd5\u6765\u521b\u5efa\u56fe\u50cf\uff0c\u5305\u62ec\u4eceHTML\u5b57\u7b26\u4e32\u6e32\u67d3\u56fe\u50cf\u3002<\/p>\n<p>b. Imagick\u6269\u5c55\uff1aImagick\u662f\u4e00\u4e2a\u57fa\u4e8eImageMagick\u5e93\u7684PHP\u6269\u5c55\uff0c\u5b83\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u56fe\u50cf\u5904\u7406\u529f\u80fd\uff0c\u5305\u62ec\u5c06HTML\u6e32\u67d3\u4e3a\u56fe\u50cf\u3002<\/p>\n<p>c. khtmltopdf\uff1a\u8fd9\u662f\u4e00\u4e2a\u5f00\u6e90\u7684PHP\u5e93\uff0c\u5b83\u652f\u6301\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3aPDF\u6587\u4ef6\uff0c\u5e76\u4e14\u80fd\u591f\u4fdd\u7559CSS\u6837\u5f0f\u3002<\/p>\n<p>\u867d\u7136\u4ee5\u4e0a\u63d0\u5230\u7684\u5e93\u53ef\u4ee5\u5b9e\u73b0\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u56fe\u7247\u7684\u529f\u80fd\uff0c\u4f46\u5728\u4f7f\u7528\u4e4b\u524d\uff0c\u4f60\u9700\u8981\u786e\u4fdd\u8fd9\u4e9b\u5e93\u5df2\u7ecf\u5728\u4f60\u7684\u670d\u52a1\u5668\u4e0a\u6b63\u786e\u5b89\u88c5\u548c\u914d\u7f6e\u3002<\/p>\n<p><strong>3. \u5982\u4f55\u5728\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u56fe\u7247\u65f6\u4fdd\u7559CSS\u6837\u5f0f\u7684\u539f\u59cb\u7cbe\u5ea6\uff1f<\/strong><\/p>\n<p>\u8981\u4fdd\u7559HTML\u5b57\u7b26\u4e32\u4e2d\u7684CSS\u6837\u5f0f\u539f\u59cb\u7cbe\u5ea6\uff0c\u4e00\u822c\u6709\u4ee5\u4e0b\u51e0\u4e2a\u8981\u70b9\u9700\u8981\u6ce8\u610f\uff1a<\/p>\n<p>a. \u786e\u4fdd\u4f60\u7684HTML\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u4e86\u6240\u6709\u7528\u4e8e\u5b9a\u4e49\u6837\u5f0f\u7684CSS\u4ee3\u7801\uff0c\u5e76\u5c06\u5176\u5d4c\u5165\u5230style\u6807\u7b7e\u6216\u5185\u8054\u6837\u5f0f\u4e2d\u3002\u8fd9\u53ef\u4ee5\u786e\u4fdd\u5728\u8f6c\u6362\u8fc7\u7a0b\u4e2d\u80fd\u6b63\u786e\u5e94\u7528\u6837\u5f0f\u3002<\/p>\n<p>b. \u786e\u4fdd\u4f60\u8bfb\u53d6\u548c\u89e3\u6790HTML\u5b57\u7b26\u4e32\u65f6\u6b63\u786e\u52a0\u8f7d\u548c\u89e3\u6790\u4e86\u5916\u90e8CSS\u6587\u4ef6\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528CSS\u89e3\u6790\u5668\u5e93\u6765\u89e3\u6790\u8fd9\u4e9b\u5916\u90e8\u6587\u4ef6\uff0c\u5e76\u5c06\u5176\u5e94\u7528\u5230DOM\u5bf9\u8c61\u4e2d\u7684\u5143\u7d20\u4e0a\u3002<\/p>\n<p>c. \u5728\u4f7f\u7528\u56fe\u50cf\u5904\u7406\u5e93\u6e32\u67d3\u56fe\u50cf\u4e4b\u524d\uff0c\u786e\u4fdd\u4f60\u5df2\u7ecf\u901a\u8fc7\u8bbe\u7f6e\u5408\u9002\u7684CSS\u6d4b\u91cf\u5355\u4f4d\uff08\u5982\u50cf\u7d20\u3001\u767e\u5206\u6bd4\uff09\u6765\u6307\u5b9a\u5143\u7d20\u7684\u5c3a\u5bf8\u548c\u4f4d\u7f6e\u3002\u8fd9\u53ef\u4ee5\u786e\u4fdd\u56fe\u50cf\u4e2d\u7684\u5143\u7d20\u4e0e\u539f\u59cbHTML\u4e2d\u7684\u5143\u7d20\u4fdd\u6301\u4e00\u81f4\u7684\u4f4d\u7f6e\u548c\u5927\u5c0f\u3002<\/p>\n<p>d. \u4f7f\u7528\u652f\u6301\u6e32\u67d3CSS\u6837\u5f0f\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u5982GD\u5e93\u6216Imagick\u6269\u5c55\u3002\u8fd9\u4e9b\u5e93\u80fd\u591f\u7406\u89e3CSS\u6837\u5f0f\uff0c\u5c06\u5176\u5e94\u7528\u5230\u56fe\u50cf\u4e2d\u7684\u5143\u7d20\u4e0a\u3002<\/p>\n<p>\u7efc\u4e0a\u6240\u8ff0\uff0c\u901a\u8fc7\u6b63\u786e\u8bbe\u7f6eHTML\u5b57\u7b26\u4e32\u4e2d\u7684\u6837\u5f0f\uff0c\u52a0\u8f7d\u548c\u89e3\u6790\u5916\u90e8CSS\u6587\u4ef6\uff0c\u5e76\u4f7f\u7528\u9002\u5f53\u7684\u56fe\u50cf\u5904\u7406\u5e93\uff0c\u4f60\u53ef\u4ee5\u4fdd\u7559CSS\u6837\u5f0f\u7684\u539f\u59cb\u7cbe\u5ea6\uff0c\u5e76\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u5e26\u6709\u6837\u5f0f\u7684\u56fe\u7247\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"\u5c06HTML\u5b57\u7b26\u4e32\u8f6c\u6362\u6210\u56fe\u7247\u5e76\u4fdd\u7559CSS\u6837\u5f0f\u662f\u4e00\u4e2a\u5728Web\u5f00\u53d1\u4e2d\u5e38\u9047\u5230\u7684\u95ee\u9898\uff0c\u5c24\u5176\u662f\u5728\u9700\u8981\u5c06Web\u9875\u9762\u6216\u5176\u90e8\u5206\u5185 [&hellip;]","protected":false},"author":3,"featured_media":261866,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/261851"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=261851"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/261851\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/261866"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=261851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=261851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=261851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}