Global Class Value Placement In Section Div?

Hi, I have two section blocks that are almost identical.

The difference is that the first section has its values placed directly in the editor, while the second gets the values via a global class.

This causes the second section to get messed up:

I’m not sure, but it could be that the second wrapper doesn’t get the values of the global class and the height value is placed in the section instead.

I mean, it should work that way since I placed the class in the section.
But how can I set the height of the wrapper div? Or is this a bug?

WordPress version: 6.2.2
Cwicly Plugin version:

You need to target the inner wrapper with Relative Styling when using a global class, since there is no direct block access to the inner wrapper.

The section block has its own logic, so it applies some styles (e.g. height, background) to the parent and the rest to the child container when applying them via block class.

1 Like

Thank you @Marius, worked like a charm :smiling_face:

and the result

Glad it worked out for you @T-low, thanks for letting me know!

For the Relative Styling combinator, I suggested you to use the child one instead of the descendant one to target explicitly (and only) the sections’ inner wrapper and not any nested div inside the section.

Another solution would be to simple target the . .cc-wrapper class.

1 Like

Thanks for the follow up, @Marius :+1:

I’ve only worked a bit with relative styling and am still quite unfamiliar with it.
Thanks for the info, here’s the visual for the non-readers ^^.


How would you target the .cc-wrapper class?
I would use the advanced → css section:

Instead of type, just use class as a Relative Styling type.
When targeting the inner wrappers’ class, you can consider to revert back to the descendent Relative Styling combinator (unless you plan to place sections inside sections, which hopefully isn’t the case).

Custom CSS only makes sense if you want to explicitly use it or if the required CSS property is not available inside the block inspector’s Relative Styling panel, which very rarely is the case.

In this case, you want to use .globalclass .cc-wrapper, not only .cc-wrapper.
The .globalclass selector automatically translates to your actual global class’ name (.my-section-class). So in case you decide to change the global class’ name at some point, you don’t have to modify the custom CSS.

Let me know in any case if you need further guidance.

1 Like

Thank you for the clarification @Marius, I really appreciate the help.

No, I don’t plan to fabricate a sectionception :joy:

Nightmare potential... open at own risk!


Is there any benefit in using the descendant combinator for this case?


Update in case CSS would be used:

I will stick with Relative Styling. I would be interested to know which method you would prefer for this case and why. The Relative Styling Type by class or by type?

1 Like

Happy to help you out @T-low :sunglasses:

:imp: :see_no_evil:

I think that’s up to you for which combinator you decide for.
It’s rather a thing of general thinking/approach which should always consider/include all possible circumstances.

My personal preference would be the descendant combinator and class name:
.globalclass .cc-wrapper

Targeting an HTML tag can make sense, but imo not in this situation.
But if you decide to do so (which would be totally fine), it is required to set child as the combinator.

That’s exactly how it works :+1:

1 Like

Thanks again for the detailed help and insight @Marius :+1:

Have a nice day :blush: