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!

asked Dec 20, 2017 at 2:09

1 Answer 1

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.
answered Dec 20, 2017 at 3:33

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.