0

I have this View: enter image description here The empty rows have a distrib0 class that should make the background red.
For that I have a custom CSS (amap.css) with tr.distrib0 {BACKGROUND-COLOR:#FF0000;} in it.
I have this amap.libraries.yml containing

amap:
  version: 1.x
  css:
    theme:
      css/amap.css: {}
  js:
      js/amap.js: {}
  dependencies:
    - core/drupalSettings

and finally, I attach the CSS with

function amap_views_pre_render(ViewExecutable $view) {
  if($view->id() == 'calendrier_des_distributions' && $view->current_display == 'page_1') {
    $view->element['#attached']['library'][] = 'amap/amap';
  }
}

As you can see in the screen capture, my CSS is there but after color.css which is part of the current theme.
And of course my background is not red!
What can I do (besides adding tr.distrib0 in tr.distrib0 to color.csswhich I'd prefer to avoid)?

1 Answer 1

0

You have added wrong CSS here. Background color will not works with tr tag because we have style of td over tr tag. Please correct with this code

tr.distrib0 td {
 background-color:#FF0000 !important;
}
4
  • I'm afraid it doesn't change anything. My CSS code is still after color.css, as you can see here
    – gbmapo
    May 29, 2018 at 10:53
  • I have updated code. Please check it now. May 29, 2018 at 10:57
  • Have you cleared website cache after saving css file ? May 29, 2018 at 11:41
  • Enjoy! In Drupal whenever you'll do any changes in files, you must have to clear cache. May 29, 2018 at 12:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.