Php 在Magento2中,我们如何使用或嵌入自定义CSS?

Php 在Magento2中,我们如何使用或嵌入自定义CSS?,php,magento,magento2,Php,Magento,Magento2,如何在Magento 2应用程序中全局添加自定义CSS文件,或在特定页面(即产品页面或签出页面)上添加自定义CSS文件 谢谢是的,你可以。请在文档中进行检查,例如: <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <

如何在Magento 2应用程序中全局添加自定义CSS文件,或在特定页面(即产品页面或签出页面)上添加自定义CSS文件


谢谢

是的,你可以。请在文档中进行检查,例如:

<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <head>
        <css src="css/styles-m.css" />
    </head>
</page>

要将自定义CSS添加到模块中,您需要在第节下的布局XML文件中包含CSS

要全局包含css,请将其添加到default.xml,或将特定文件添加到所需文件(例如catalog\u category\u view.xml)

要在XML文件中添加的代码:

<?xml version="1.0"?>
 <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
   <head>
      <css src="css/yourcssfilename.css" />
 </head>
</page>
运行以下命令并检查:

php bin/magento缓存:干净

php bin/magento设置:静态内容:部署

php bin/magento安装程序:升级

#your CSS code