This works well, but on one page I want the background-color of my collection to be #000000. I can’t seem to be able to create a second class with a different background colour that affects the collection item borders, can someone please offer me some help with the CSS I need to make this happen?
Is this the thing you would want to apply to all collections? Looks like this is the native collection’s div name so if you can’t remove this, there needs to be an overwrite with !important happening on the darkcontainerborder part perhaps.
div[class*="pages-component-renderer___StyledDiv7"] – I don’t see this attribute in the collection component you’re trying to target.
If you’re trying to target the cards, try using [data-testid="cc-card"] instead.
Your images are shrinking because you’re applying a 4px border . Either reduce the border width or remove the border entirely to prevent the content from being compressed.
The .collection-item seems to apply to all collections, so by default, they have the #31404C border.
neither .collection-item-dark and .customborder do not seem to override this when I apply either of them to the collection I am trying to have a black border for. I feel like I need a second version of .collection-item with the different settings (or one that applies the teal border and leave it as borderless by default) but I am unsure what CSS code is needed to achieve this
Are you applying a custom class per specific collection component? It would help to see the settings in your Glide dashboard where the class is assigned, and please also share a screenshot of your custom CSS.
Avoid using broad selectors like .collection-item > div or .collection-item-dark > div unless you are certain of the exact target element, as this can unintentionally affect multiple nested elements.
If your intention is to have one collection use the default style and another use a custom style, then proper scoping is required. For example: .custom-class [data-testid="cc-card"] { ... }
should work as long as .custom-class is correctly assigned in the Glide component options tab.
If you are trying to achieve dynamic or conditional styling behavior per collection instance, you may also find this approach relevant:
If you want to avoid layout shift (e.g. border affecting image size), you can use outline instead of border, since outline does not affect element dimensions.