-1

I'm trying to apply CSS styles to a specific node (all part of the same content type).

I'm using these CSS styles.

.page-node-534 .featureWrap article {
  position: relative;
  left: 112px;
}

This isn't working. I checked the body and it contains the class .page-node-534.

What am I doing wrong?

5
  • 1
    Have you tried to apply a style to the .page-node-534 class without the following classes? Maybe it's about the .featureWrap or article?
    – Volker
    Oct 18, 2017 at 10:46
  • I actually haven't. I 'll try that Oct 18, 2017 at 11:03
  • Just to give you an update. I tried applying a red background to the class .page-node-534 but that didn't work Oct 18, 2017 at 11:08
  • I have also found that if I apply the style inside of firebug in the browser, it does work using the same class. So it would seem that what I'm applying to the style.css file is not Oct 18, 2017 at 11:45
  • In Firebug you'd see the actual css styles when your class is selected. This implies that your css file is probably not updated. Try clearing your caches and check again.
    – Volker
    Oct 18, 2017 at 12:11

1 Answer 1

1

As a general suggestion, you may want to utilize the following modules on your site to avoid having id specific css:

These modules allow content managers/site builders to apply general classes to menu items, blocks, and nodes that are agnostic to the Drupal assigned IDs. (particularly helpful if a piece of content is manually added on a device environment and manually added on a staging/test environment, and prod environment - since auto assigned IDs will likely be different)


If you are trying to apply css to a class using one of these modules, context module, or even the system generated classes or IDs and still do not see your styles, here are some troubleshooting suggestions.

Open the css file being loaded and check for your latest styles. If you see the edits there, there's most likely an error in your css targeting. If you don't see the updates, check the following:

  1. Check to make sure your css file is properly being loaded in your theme or module.
  2. Clear the Drupal (and possibly Varnish) caches
  3. Hard refresh the page in your browser to ensure loading latest copy of css.
1
  • The use of those modules helped me to style the specific nodes. Do you know if there is a way to give a drupal field (eg. an image) a specific class? Oct 18, 2017 at 14:30

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