Issue #2331💬 AnsweredOpened October 16, 2019by hellocaio0 reactions

CSS rules overwritten by cssComposer.setRule(...)

快速解答by artf

When I change one style (i.e. text color), I lose any other styles that were previously set by my custom sidebar (i.e, font-family, font-size). It's not clear to me what do you change and where the style is overwritten... maybe you can provide a live demo of your case?! Doing this cssComposer.setRule("p", { "font-fami...

Read full answer below ↓

Question

My site has a custom sidebar to set site-wide colors, font-families, font-sizes and so on. When I change one style (i.e. text color), I lose any other styles that were previously set by my custom sidebar (i.e, font-family, font-size).

To change these styles I am doing:

 cssComposer.setRule("p", { "font-family": value });
 cssComposer.setRule("h1", { "font-size": value });
 cssComposer.setRule("a", { "color": value });

Is this the correct way going about changing site-wide styles? Why is it getting overwritten?

Answers (2)

artfOctober 19, 2019

When I change one style (i.e. text color), I lose any other styles that were previously set by my custom sidebar (i.e, font-family, font-size).

It's not clear to me what do you change and where the style is overwritten... maybe you can provide a live demo of your case?!

Doing this cssComposer.setRule("p", { "font-family": value }) is correct but it doesn't change the way CSS work, if you have another rule with a strongest selector, that will gonna win

no-response[bot]October 29, 2019

This issue has been automatically closed because there has been no response to our request for more information from the original author. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further.

Related Questions and Answers

Continue research with similar issue discussions.

Paid Plugins That Match This Issue

Curated by issue keywords and label relevance to help you ship faster.

View all plugins

Loading paid plugin recommendations...

Free option

Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.

Browse free plugins →
Premium option

Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.

Browse premium plugins →

Browse Plugin Categories

Jump directly to plugin category pages on the marketplace.