0

suppose I need to add following changes in my css:

.border{1px solid #cecece}
.box{float:left}

I am stucked to add these in my styles, i can only see .less files and not sure how it works.

2 Answers 2

2

In your custom theme , Extend your theme CSS file under Magento_Theme\web\css\source _extend.less

you need to create this less file under theme module and then you can write your new styles here or can override existing .

7
  • i already extended theme and have written css in _extend.less but it is not reflecting. I wrote: .border{1px solid #cecece} .box{float:left} Commented Jun 17, 2017 at 11:13
  • run upgrade and static content deploy command , extended less takes effect after these commands Commented Jun 17, 2017 at 11:15
  • Another way adding CSS is adding in \web\css\bootstrap.css and call this file in head block Magento_Theme\layout\default_head_blocks.xml <css src="css/bootstrap.css" /> Commented Jun 17, 2017 at 11:17
  • ran the deploy command but changes are not visible in any file of css, i checked styles-m.css and others too Commented Jun 17, 2017 at 11:20
  • crosscheck your file names like " _extend.less " and send me your extended path , or have you tried another way ? this is wrong styling " .border{1px solid #cecece} " Commented Jun 17, 2017 at 11:23
0

Try this way to add css to frontend page:

  1. Put your css into app/code/VendorName/ModuleName/view/frontend/web/css/custom.css.
  2. Create xml layout to call your css file, e.g: app/code/VendorName/ModuleName/view/frontend/layout/default.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="VendorName_ModuleName::custom.css" />
        </head>
    </page>
    
  3. Run php bin/magento setup:static-content:deploy

Your Answer

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.