4

I have a css file in web/css/style.css in my own module . but it is not working . i have called it in my vendor/module/view/frontend/layout/xmlfile . Note : I don't want to add it in theme css i want to add it in my own module .

<head>
    <css src="Vendor_Module::css/style.css"/>
</head>
  • have you put css file in web/css/styles.css in module ? – Ansar Husain Sep 18 '18 at 5:50
  • yes vendor/module/view/frontend/web/css/style.css – Flutterer Sep 18 '18 at 5:51
  • did you run deploy static command also ? – Ansar Husain Sep 18 '18 at 5:52
  • yes , cache flush also . – Flutterer Sep 18 '18 at 5:52
3

Here are step you can take to check your css is loading.

  1. Make sure layout file name is correct

  2. added the xml tag <?xml version="1.0"?>

  3. using page_configuration.xsd

     <?xml version="1.0"?>
     <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="1column" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
     </page>
    
  4. deploy content php bin/magento setup:static-content:deploy

  5. clear magento cache php bin/magento cache:clean

  6. make sure file located in pub/static/frontend/spacename/themename/en_US/modulename/

  7. Use Incognito mode in browser to avoid browser cache problem

  • static-content deployed .. cache:flush ... pub/static/frontend/spacename/themename/en_US/modulename/ has style..css file . but it is empty ... but still no effect . – Flutterer Sep 18 '18 at 13:49
  • @samairali remove css file and generate content again. – Qaisar Satti Sep 19 '18 at 7:00
1
  1. check your theme you are using, put css file on your theme
  2. check xml file defined by utf-8 format
  3. try add code <update handle="your_xmlfile"/> to your xml file
  4. make sure your store deployed, cleared cache, cleared host cache ...
  5. setup correct permission for your store folder

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.