2

I am new with Magento.

By following instruction found in here: http://devdocs.magento.com/guides/v2.2/frontend-dev-guide/css-topics/css-themes.html

For me no success to add a css file.

This is what I have done:

app/code/MYVendor/mytheme/etc/module.xml

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
  <module name="MYVendor_mytheme" setup_version="1.0.0">
    <sequence>
      <module name="Magento_Theme"/>
    </sequence>
  </module>
</config>

app/code/MYVendor/mytheme/registration.php

<?php
\Magento\Framework\Component\ComponentRegistrar::register(
  \Magento\Framework\Component\ComponentRegistrar::MODULE,
  'MYVendor_mytheme',
  __DIR__ );

app/design/frontend/MYVendor/mytheme/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/styles-l.css" media="screen and (min-width: 768px)"/>
  </head>
</page>

app/design/frontend/MYVendor/mytheme/web/css/styles-l.css

body {
  background-color: blue;
}

I also have run:

php bin/magento deploy:mode:set developer
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento indexer:reindex
php bin/magento cache:flush

But no luck.

Can anybody help me please! Thank!

0
  1. You need active your theme in dashboard(content -> Design -> Configuration).
  2. If you active your theme, refresh the site cache in dashboard(System -> Cache Management), and Ctrl+F5 to refresh your browser cache.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.