0

For example - I have enabled Zircon as my default theme. I want the user menu account to appear on left. I want to add a custom CSS file where I can write a CSS elements and add to a default theme on site.

1
  • 1
    You can define your own library and attach it via hook_page_attachments or you can alter the theme's library and add your css in there.
    – user21641
    Feb 17 '16 at 9:13
3

In Drupal 8, stylesheets (CSS) and JavaScript (JS) are loaded through the same system for modules (code) and themes, for everything: asset libraries. Asset libraries can contain one or more CSS assets, one or more JS assets and one or more JS settings.

More details on https://www.drupal.org/developing/api/8/assets

2

Add your custom CSS file to themes/zircon/css/ lest suppose your file name is yourfile.css, then open zircon.libraries.yml and add your Css file name to end of this section

css:
  base:
   includes/bootstrap/css/bootstrap.css: {}
   includes/bootstrap/css/bootstrap-theme.css: {}
   includes/fonts/oswald_regular/stylesheet.css: {}
   includes/fontawesome/css/font-awesome.min.css: {}
   includes/slick/slick/slick.css: {}
   includes/slick/css/style.css: {}
   includes/monokai/monokai.min/css: {}
   includes/flexslider/flexslider.css: {}
   css/html.css: {}
   css/page.css: {}
   css/block.css: {}
   css/view.css: {}
   css/slideshow.css: {}
   css/responsive.css: {}
   css/print.css: { media: print }
   css/yourfile.css: {}

save and close the file and clear the cache.

2
  • adding a css file name in zircon.libraries.yml is giving an error-The website encountered an unexpected error. Please try again later.
    – 39467
    Feb 17 '16 at 11:59
  • @NewBorn-Drupalist try with put space after colon ` css/yourfile.css: {}`
    – Yuseferi
    Feb 17 '16 at 13:26

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.