I Hope this is useful for You,
add your CSS file to
app/code/vendor/module/view/frontend/web/css/mycss.css
mycss.css
body{
background-color:green;
}
Then add CSS File to Your layout File.
app/code/vendor/module/view/frontend/layout/test_index_index.xml
<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_layout.xsd">
<head>
<css src="css/mycss.css" />
</head>
<body>
<referenceContainer name="content">
<block class="vendor\Module\Block\class" template="vendor_Module::class.phtml"/>
</referenceContainer>
</body>
</page>
Remove this folder
rm -rf var/cache/*
rm -rf var/page_cache/*
Remove pub/static
rm -rf pub/static/*
Next generate Static Content:
php bin/magento setup:static-content:deploy
Now, try, Its worked for me. Never forget to add the asterisk behind the folders you're deleting since they contain an .htaccess file that might be relevant for your shop to load properly. The asterisk prevents Dot-Files from being deleted.