NO BUG: CSS @import in Custom Code

Hi builders,

I started using the @import function to use a unique source for the backend and builder themes of all my websites. I tried linking my source stylesheet in Brick’s custom code, but it doesn’t seem to work at all.

It works when I copy the code directly, but not when I try to import it via CSS – a problem I have not encountered outside of Bricks. I was careful to place that code at the start:
@import url(“https://website.com/wp-content/uploads/css/stylesheet.css”);

Is Bricks blocking that CSS rule?

Thanks for your help!

I ended up adding a PHP rule, works just as well. I would love to know how to prevent Bricks from skipping @import rules though.

HI @mrplum,

when you add the CSS there, it will be mixed with other CSS rules on the front end, so the @import statement will not actually be at the top of the decalration. If you take a look at the generated CSS, you will see that it’s inside one stylesheet.
Unless, I think, if you use “external styles”, then I think it should be rendered on it’s own.

I think enqueuing it via PHP using a code snippet or child theme is safest though, as you have full control over it… :slight_smile:

Best regards,
Matej

Thanks a lot for your answer! Yeah, PHP enqueuing seems the way to go.

1 Like