WAIT: Gradient overlay forces position: relative on every child and breaks stretched links

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

  1. Create a global class card on a Div with position: relative and a gradient background set to apply as an overlay.
  2. Inside the card, add a Heading containing a link, and give the link ::after { content: ""; position: absolute; inset: 0; }.
  3. 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: 0 to the element (or isolation: isolate) and put the overlay ::before at z-index: -1. Then the children don’t need position: relative.
  • Make the child rule optional (a toggle on the gradient control).
  • At least document the side effect next to the overlay option.

Hi Ben,
Thanks for the detailed report. This should be fixed in Bricks 2.5 beta. The changelog includes:

Gradient/Overlay: Preserve child positioning in layout elements with overlay gradients

Could you test the beta on a staging site and let us know whether your stretched links now work correctly?