Area: Global classes / element styles › Gradient (apply to: overlay)
Environment
- Bricks 2.4.5
- WordPress 7.1.4, local install
- Active plugins: Gravity Forms 3.2.3, WPCodeBox 2 1.4.1 (site CSS/PHP snippets), Disable Comments, WPS Hide Login
- Custom breakpoints, mobile-first: Mobile portrait is the base breakpoint, then Mobile landscape (min-width 639px), Tablet portrait (1023px), Laptop (1279px), Desktop (1535px)
- Bricks settings › Performance: CSS loading method set to external files
Summary
When a gradient is applied as an overlay, Bricks also outputs:
:where(.my-class.brxe-div > :not(figcaption)) { position: relative; }
This sets position: relative on every direct child. A common accessible card pattern uses one link whose ::after covers the whole card (a “stretched link”). The pseudo-element is positioned against the nearest positioned ancestor, which is now the link’s own parent, not the card, so only that child is clickable.
Steps to reproduce
- Create a global class
cardon a Div withposition: relativeand a gradient background set to apply as an overlay. - Inside the card, add a Heading containing a link, and give the link
::after { content: ""; position: absolute; inset: 0; }. - On the front end, click anywhere on the card outside the heading.
Expected
The whole card is clickable.
Actual
Only the heading area is clickable. The heading wrapper has position: relative from the overlay rule, so the ::after only covers the heading.
Source
includes/assets.php:3934
$css_rules[ ":where($css_selector > *:not(figcaption))" ] = [ 'position: relative' ];
Workaround
Remove the gradient overlay and darken the background image another way (we used a CSS brightness filter on the background <img>).
Suggested fix
Ideas, in order of preference:
- Add
z-index: 0to the element (orisolation: isolate) and put the overlay::beforeatz-index: -1. Then the children don’t needposition: relative. - Make the child rule optional (a toggle on the gradient control).
- At least document the side effect next to the overlay option.