CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Custom CSS
Pages: [1]

Author Topic: Custom CSS  (Read 2413 times)

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Custom CSS
May 09, 2013, 02:18:10 am
I've just upgraded a Drupal 6 site to CiviCRM 4.3.2, and spotted a problem with the display of contact names when viewing a contact record. The default CSS is:
Code: [Select]
#crm-container div.crm-summary-contactname-block {
    margin-top: -10px;
    padding-bottom: 8px;
}
Removing 'margin-top: -10px;' solved it for me. So I thought about how best to implement this change to the CSS. I've not often had much need to alter CiviCRM's default CSS, and as I'd just upgraded I thought I'd check the documentation, which appeared to offer very little information (maybe I missed something).

There is an option to set a URL to a custom CSS file, and I'm sure that in the past I've just copied the whole of civicrm.css to a new location outside of the codebase (to avoid being overwritten during upgrades), implemented my tweaks in that file, and set the URL to point to this custom CSS file, which CiviCRM then uses instead of the default. Only it doesn't work (in 4.3.2 at least), because civicrm.css includes relative references to external image files, so all those get broken.

I see that CiviCRM also offers an extras.css file that we can use to implement any additional styling, but I'm unclear as to whether styles implemented in extras.css override rules in civicrm.css or not, and in any case as extras.css is located within the upgradeable codebase, it is likely that this file will get overwritten when an update is done, so that's not ideal either.

So I fall back to implementing my custom styling as part of my Drupal theme, knowing that as this is stored within my sites directory I've got a much better chance of not overwriting it.

I would be keen to learn what's considered best practice in terms of customising CiviCRM's CSS, and what approaches other people take. And if someone can clarify when and how to use CiviCRM's custom CSS URL and the precedence of extras.css that would be helpful. I'll aim to update the documentation in light of what is learned.

Thanks
Graham
« Last Edit: May 09, 2013, 11:20:14 am by Upperholme »
Graham Mitchell
http://mc3.coop

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Custom CSS
May 09, 2013, 10:14:35 am
Couple issues with this:

1) I think the way we mark-up the contact name is not great. We are using a div when we probably should be using an h1 tag. We should fix this although I'm not sure if it makes sense to do it mid-release cycle in 4.3 or wait for 4.4. One could make a case for both.

2) I've filed a mental issue recently to make our css customizations a bit easier. Might as well file a real issue. Here it is: CRM-12578 - Improve custom css options

3) For now yes I would recommend adding the css to your theme. You could include it in a separate css file and conditionally include it in your theme's template.php like so:
Code: [Select]
if (arg(0) == 'civicrm') {
  drupal_add_css('path/to/your/file.css');
}
Try asking your question on the new CiviCRM help site.

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Custom CSS
May 09, 2013, 11:28:16 am
Thanks Coleman

I would agree that using an h1 would seem more logical and make some more sense semantically.

I think the concept of extras.css is sound, i.e providing a central location, independent of the CMS, in which to store modifications to the core CiviCRM CSS (if indeed that's what extras.css does), is a good idea. The downside of the current extras.css set up is that it's location makes it easily overwriteable, and it's not clear whether rules placed in extras.css override the core civicrm.css
Graham Mitchell
http://mc3.coop

slamorte

  • I’m new here
  • *
  • Posts: 27
  • Karma: 1
  • CiviCRM version: 4.4.4
  • CMS version: Drupal 7
  • MySQL version: 14.14
  • PHP version: 5.4.4-14+deb7u8
Re: Custom CSS
December 04, 2013, 01:27:11 pm
This is the problem I am having. My theme's custom.css does not override the civicrm.css, which has a heavier weight.

The alternative seems to be modifying the css inside the civicrm module folder, or marking all my changes in the custom.css with !important. Neither seem optimal.

Upperholme

  • Administrator
  • Ask me questions
  • *****
  • Posts: 568
  • Karma: 8
    • MC3
  • CiviCRM version: 4.x
  • CMS version: Drupal 6.x/7.x, Wordpress, Joomla
Re: Custom CSS
December 04, 2013, 01:44:40 pm
I think the latest version of CiviCRM has changes to the CSS set-up in line with the discussion in this thread. Worth looking into if you've not already done so, as it may address your issue.
Graham Mitchell
http://mc3.coop

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Custom CSS
December 04, 2013, 01:49:54 pm
Whoops. You're right. The fix that went into 4.4.1 did not set the custom css file's weight correctly. I will fix that today for the release of 4.4.3.
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Post-installation Setup and Configuration (Moderator: Dave Greenberg) »
  • Custom CSS

This forum was archived on 2017-11-26.