1

In M2 they use custom .media-width mixin rules to add to styles-m.css or styles-l.css.

//
// Common
// _____________________________________________
& when (@media-common = true) {
 .catalog-product-view {
 }
}
//
// Mobile
// _____________________________________________
.media-width(@extremum, @break) when (@extremum = 'max') and (@break = @screen__m) {
}
//
// Desktop
// _____________________________________________
.media-width(@extremum, @break) when (@extremum = 'min') and (@break = @screen__m) {
}

Is there a similar method for adding style rules to print.css?

Manoj Deswal
5,80325 gold badges29 silver badges50 bronze badges
asked Jul 12, 2017 at 8:54
1
  • Yes you can use similar way, but extend your print.less and keep original file , you can make addition but do not remove original styles. Commented Jul 12, 2017 at 9:19

2 Answers 2

1

print.less file is used for print styles:

vendor/magento/theme-frontend-blank/web/css/print.less

So you should just need to extend/overwrite this file in your theme.

More info found on the dev docs here - http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/css-topics/css-themes.html

answered Jul 12, 2017 at 9:41
4

If you use a custom theme you can go to the theme's path:

app/design/frontend/YourVendorName/YourThemeName/web/css and do a file called print.less.

Into that file copy and paste the content from this file: vendor/magento/theme-frontend-blank/web/css/print.less.

After that add the style changes that you want to do in app/design/frontend/YourVendorName/YourThemeName/web/css/print.less and then run this command:

php bin/magento setup:static-content:deploy

I hope this helps.

answered Jul 12, 2017 at 10:19
3
  • The static-content deploy command is only required when running in production mode btw. Commented Jul 12, 2017 at 10:24
  • I'm running in developer mode and the print.less in my theme doesn't get processed unless I run deploy : ( Commented Aug 31, 2018 at 17:31
  • Solution is not working Commented Jul 17, 2019 at 13:26

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.