如何在magento 2中的自定义主题中覆盖CSS文件 [英] How to override CSS file in custom theme in magento 2

查看:387
本文介绍了如何在magento 2中的自定义主题中覆盖CSS文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Magento 2中,我创建了新主题.我尝试添加更少的文件app/design/frontend/mage_vender/sample(theme)/web/css/source‌/_extend.less. 但这并没有显示变化. 请任何人告诉我,我们该怎么办? 我正在使用magento 2.1.3 谢谢

In Magento 2, I have create new theme. I tried to add less file app/design/frontend/mage_vender/sample(theme)/web/css/source‌​/_extend.less. But it is not showing changes. Please can anyone tell me, how can we do ? I am using magento 2.1.3 Thank you

推荐答案

要做的第一件事就是创建主题,不要忘记添加所有必需的文件,例如theme.xmlregistration.php.上一次我查看magento 2文档时,它是最新的,并且具有有关如何创建新主题的足够信息.

The first thing you need to do is to create your theme, don't forget to add all the required files like the theme.xml and registration.php. Last time I checked the magento 2 documentation it was up to date and had enough information regarding on how to create new themes.

您需要做的第二件事是将新主题添加到theme.js中,否则您将无法将较少的新文件编译为CSS.您可以通过在/dev/tools/grunt/configs/themes.js

Second thing you need to do is to add your new theme to the theme.js, other wise you will not be able to compile your new less files into CSS. You do this by adding a new json group into /dev/tools/grunt/configs/themes.js

例如,现在要覆盖较少的文件,让_navigation.less说,您只需将其放在/app/design/frontend/[YOUR_THEME]/web/css/source/_navigation.less

Now to override less files for example lets says the _navigation.less you just need to put it under /app/design/frontend/[YOUR_THEME]/web/css/source/_navigation.less

然后执行grunt refresh,添加新文件时始终执行此操作,如果要编辑已添加的文件,则始终执行grunt watc h.

Then do a grunt refresh, you do this always when you add new files and grunt watch if you're editing one that has already been added.

这篇关于如何在magento 2中的自定义主题中覆盖CSS文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆