b2evolution b2evolution

  • Sign in
  • Sign up
  • About
  • Downloads
  • Hosting
  • Docs
  • Support
  • Sign in
  • Sign up
  • Manuals Home
  • Latest Updates
 
  1. b2evolution CMS User Manual
  2. Developer Reference
  3. Website Skins/Themes
  4. CSS Guidelines

CSS Guidelines

See ale Coding Standard Guidelines.

Do NOT write CSS, write LESS!

Always write your code to a .less (or .sass) file and let Grunt compile it to a .css file and even a .min.css file.

Use Grunt all the time

Learn to use grunt in the background. It will automatically recompile your LESS to CSS when you make a change.

Use modules

Every time you find identical LESS/CSS code in multiple files, or any time you want to copy/paste code to multiple files yourself, create a module!.

A module should be a file like /rsc/less/module_name.module.less.

Then, in each LESS file where you would have had duplicate code, add @import '.../module_name.module.less'.

This applies to:

  • styles used in front office + backoffice
  • styles used in multiple default skins
  • styles used in both bootstrap and non-bootstrap skins

This does *NOT* apply to:

  • styles used in multiple custom skins that are not part of the core distribution

Class names

  • Use _ (not -) in class names.
    • We do this because it makes it easier to double click a class name to select it entirely.
    • This also actually helps identifying bootstrap classes versus properietary classes.
  • When the core (or a widget, etc.) outputs a class="...", your class names should start with a very specific prefix like evo_.
    • For example you should use evo_username rather than username or evo_photo instead of photo.
    • This avoids conflicts with other things users may have in their skins.
    • Another example of a prefix is ufld_ which means "User field". The probability that this prefix is used by someone/something else on a page is very low.
    • Using poorly specific prefixes is nto a good idea. For example new_username or big_photo does not count as a prefix.
    • Class names without an evo_ or other very specific prefix should be used only in the LESS/CSS files of skins.
    • Any new classname added to the core must follow this rule. The reason why this rule is not enforced for existing class names is backward compatibility. If we change all existing class names suddenly, it will break many skins.
  • Use __ (double underscore) for modifier classes.
    • For example, you may have

      <a href="..." class="round_button"><span class="round_button_icon">...</span><span class="round_button_text">...</span></a>

      that is used several times on a page. If you want to modify it, use modifier classes like round_button__orange or round_button_icon__big like this:

      <a href="..." class="round_button round_button__orange"><span class="round_button_icon round_button_icon__big">...</span><span class="round_button_text">...</span></a>

Use margins rather than paddings

When equivalent, prefer margins to paddings.

Asymetric paddings are generally not cool. They make things ugly if we change the background color, for example on hover. Of course, you still need asymetric paddings if you need to compensate for an icon/glyph that is not well centered.

Tags: guidelines
Created by miloszivojinovic • Last edit by fplanque on 2020-03-05 14:03 • •

No feedback yet

On this page

  • Do NOT write CSS, write LESS!
  • Use Grunt all the time
  • Use modules
  • Class names
  • Use margins rather than paddings

Search the Manual

Content Hierarchy

  • b2evolution CMS User Manual
  • User's Guide
  • Installation / Upgrade
  • Front-office Reference
  • Back-office Reference
  • Developer Reference
    • Website Skins/Themes
      • Skin Development Primer
      • Loading additional resources into a skin
      • Where are the skin files?
      • CSS Guidelines
      • Targeted CSS Selectors
      • Introducing evoSkins
      • Modifying evoSkins
      • Creating evoSkins
      • Skin Tags / API
      • Styling widgets
      • Skin Quality Control
      • Using HTML 5 tags
      • Using Custom Item Templates
      • Using bootstrap classes in footers
      • Using Grunt
      • Dev Menu
      • How to add a Google Font (WebFont) ?
      • Custom Fields in a Template
      • Site Skins
    • Email Skins/Themes
    • b2evolution Files
    • Website Integration
    • Plugins
    • Debugging
    • Technical Reference
    • Hacks
    • Credits
    • Development
    • How to... (Customize)
    • Scheduled Tasks Reference
  • Operations Reference
  • Advanced Topics
  • Glossary
  • Archives
CCMS

This online manual is powered by b2evolution CMS – A complete engine for your website.

About b2evolution

  • What is it?
  • Features
  • Getting Started
  • Screenshots
  • Online demo
  • Testimonials
  • Design philosophy
  • Free & open source
  • Terms of service

Downloads

  • Latest releases
  • Skins
  • Plugins
  • Language packs

About us

  • About us
  • Contact

Webhosting Guide

  • Web hosting blog
  • Best web hosting
  • Cheap web hosting
  • Green web hosting
  • Hosting with SSH
  • VPS hosting
  • Dedicated servers
  • Reseller hosting
  • Int'l: UK / France

Docs & Support

  • Online manual
  • Forums
  • Hire a pro !

Other

  • Adsense
  • Press room
  • Privacy policy

Stay in touch

  • GitHub
  • Twitter
  • Facebook
  • LinkedIn
  • News blog
  • RSS feed
  • Atom feed

Founded & Maintained by François Planque