Magento 2 自定义主题 css 未显示
Magento 2 custom theme css not showing
我创建了一个名为 'gvtheme' 的自定义 Magento 2 主题。
css 的文件夹布局是:frontend->Magento->gvtheme->web->css->source->style.css
在style.css中我输入了body: background-color: red;只是为了测试它是否有效。当我检查 chrome 中的 body 标签时,它没有显示,甚至没有作为覆盖样式显示。
在 Magento 2 后端的 Content/Design/Configuration 中,显示 'Default Store View' 和其他两个视图的主题是 'gvtheme'。它之前显示为 'Luma'。
在网站的前端,它不再显示 'Luma' 徽标和样式。我已经刷新了所有缓存,包括 'Flush Javascript/CSS Cache'。
有谁知道为什么这可能不起作用?
任何帮助将不胜感激!
原来我需要添加 'custom-theme'->'Magento_Theme'->'layout'->'default_head_blocks.xml'。在该文件中我需要添加:
<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/source/style.css" />
</head>
我创建了一个名为 'gvtheme' 的自定义 Magento 2 主题。 css 的文件夹布局是:frontend->Magento->gvtheme->web->css->source->style.css
在style.css中我输入了body: background-color: red;只是为了测试它是否有效。当我检查 chrome 中的 body 标签时,它没有显示,甚至没有作为覆盖样式显示。
在 Magento 2 后端的 Content/Design/Configuration 中,显示 'Default Store View' 和其他两个视图的主题是 'gvtheme'。它之前显示为 'Luma'。 在网站的前端,它不再显示 'Luma' 徽标和样式。我已经刷新了所有缓存,包括 'Flush Javascript/CSS Cache'。 有谁知道为什么这可能不起作用? 任何帮助将不胜感激!
原来我需要添加 'custom-theme'->'Magento_Theme'->'layout'->'default_head_blocks.xml'。在该文件中我需要添加:
<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/source/style.css" />
</head>