SOLVED: The custom css class changed to root

Bricks Version: 1.3.7(this issue was there since beginning)
Browser: Chrome 90
OS: macOS / Windows / Linux / etc.
URL: no site investigation needed.

I noticed this issue for a very long time. I decided to report it today.

Every time I write custom CSS, I noticed that the class name will change to root

Example:

.myclass {color:#333}

Then I edit the next elements, then again come back to the same element, the custom CSS will become this.

root {color:#333;}

I think this one needs to be solved.

I don’t think the builder should change it automatically for us unless we type that ourshelves.

Hi Jornes,

can you share a screencast showing how to replicate the issue?

Best regards,
timmse

Hi @timmse

Here you go.

Have you checked this out, @timmse ?

Hi Jornes,

root is used as a placeholder in this case, just as it is for an ID. If you look at the generated code, you will see that the styles are applied to the class. This approach works fine for both IDs and classes, so I don’t see any reason to change it - especially since it would be a massive effort.

In your case this means that root = .iconbox-1, i.e. the class selected above. Alternatively, you can add your custom code to Bricks > Settings. This way, you have everything centrally in one place, which makes maintenance much easier.

Best regards,
timmse

Maybe I did not explain it well?

What I am concerned about is that the class name I typed in the custom CSS block would automatically be changed to root(in the builder only).

I hope it remains what I typed. When I type .iconbox-1, then let it stay as it should. Don’t ever change the class names typed in the Custom CSS block to root.

It won’t happen in the other builders.

I understood you correctly and explained why it is the way it is.
Why and what are you concerned about?

If something wouldn’t work, I could understand your concern. However, the class assignment works fine, so I don’t see any reason to worry.

Just because it’s different in other builders doesn’t mean we can’t do it differently, right? :slight_smile:

1 Like

It’s okay then. TQ! :pensive:

I think bricks did this well. Root is great as it allows you to select children easily.

Otherwise, you could just use the code block for what you mentioned?

1 Like

Hi,

sorry for bringing up this post again, but I don’t think this is the correct solution. If I write something in CSS, it should stay as it is and only convert “root” to the actual root class.
In the @jornes example, I can understand that it is converted, because .myclass is acually root of the element, but take a look a my example:

The class is called “basic-card” and elements inside this class are “basic-card-{element-name}”

Now look what happens.

I don’t think this is good practice, why would Bricks convert “.basic-card-title” to “root-title”… It doesn’t make sens to me.

1 Like

Hi, I want to chip into this as well.

Case:
I created a styles page to set up some CSS styles for the site, since the theme styles don’t support CSS.

Now after I created the classes on this page, I want to move the CSS over to the customizer / child theme / metabox / snippets – whatever people choose, to have it in one place.

So I go into the class for my links. But it now says Root a:hover
So instead of:

.darkbg-link:link {
color: #ffffff;
text-decoration: underline;
}

.darkbg-link:hover {
color: #yellow;
text-decoration: underline;
}

.lightbg-link:link {
color: #505050;
text-decoration: underline;
}

.lightbg-link:hover {
color: #000000;
text-decoration: underline;
}

I get:

Root a:link {
color: #ffffff;
text-decoration: underline;
}

Root a:hover {
color: #yellow;
text-decoration: underline;
}

Root a:link {
color: #505050;
text-decoration: underline;
}

Root a:hover {
color: #yellow;
text-decoration: underline;
}

But that now doesn’t say which class it is anymore once it’s out of context.

Last week I asked what the best practice is for CSS in Bricks since I can’t find much about it. And I got only one reply to it from another user saying; it doesn’t matter in Bricks.

But apparently it does?
Because root equals saying: you need the CSS in the CSS inputbox together with the active class name.

If not; please teach me (everyone) how you meant it to be done in Bricks.

Hi Matej,
Thanks so much for bringing this up again.

I was able to reproduce the issue and added it to our bug tracker.

Best regards,
timmse

@matejmohar @MarketingSpectrum
We’ve fixed this bug in Bricks 1.5.1, which is soon available as a one-click update in your WordPress Dashboard.

Please let us know if you are still experiencing issues.

Best regards,
timmse

1 Like

Thanks a lot Timmse!
Will do!