Block CSS collide with CSS rules already defined in template
No community answers yet. Open the original discussion on GitHub to share your solution.
Question
For block specific styles I'd recommend just using
styletagcontent: ` <section class="big-hero">...</section> <style> .big-hero{...} .... </style> `,If you want to preload external stylesheet inside the canvas
var editor = grapesjs.init({ ... canvas: { styles: [ 'https://...', ... ] } });
Hi @artf
When using <style> tag to define styles inside the 'content', after the block is dropped on the canvas, the css rules of the block overrides those of the elements that already in the canvas with the same selector.
For example, if the block has the following rules
.class1{ color: #fff; }
After the block is added, the other elements not inside the block that also have the 'class1' will also have the color changed to white
Even after I removed the newly added block, the new styles still exists
Any quick way to limit the scope of the block CSS to that particular block only? Or I need to update every selectors to prevent this happening?
Originally posted by @charlieshum1 in https://github.com/artf/grapesjs/issues/195#issuecomment-490852070
Answers (0)
No answers yet.
Related Questions and Answers
Continue research with similar issue discussions.
Issue #1807
GrapeJs framework breaks on adding external stylesheet
When i add my external stylesheet using the grapesjs framework no more works. How can I have the style sheet as well as the grapesjs framew...
Issue #3401
Can style manager always generate IDs instead of using already defined element's class ?
When we style an element in the editor, if this element doesn't have neither a class or an id, the style manager generate a new id with the...
Issue #442
Is it possible to include an external stylesheet in the grapesjs canvas?
We want to create some custom components whose style changes according to an external theme css (there can be different themes), and we wan...
Issue #3219
Add Type for block and css with class name
Hi @artf I am stuck on one thing I want to add one block in which I want to add style with the class name also Here is my code -: This give...
Paid Plugins That Match This Issue
Curated by issue keywords and label relevance to help you ship faster.
Loading paid plugin recommendations...
Check the open-source GrapesJS plugins on GitHub or run a quick search in our free catalog.
Browse free plugins →Premium plugins ship with support, regular updates, and production-ready features — save days of integration work.
Browse premium plugins →Related tutorials
In-depth guides on the same topic.
Tutorial
How to Build a Production GrapesJS Editor: The Complete Walkthrough of Brief, Preset, Plugins, and Services
A complete walkthrough of building a production GrapesJS editor: how to choose a preset, pick plugins, and scope setup services without burning a sprint.
Tutorial
GrapesJS Inline RTE Plugins Update: CKEditor 5 v0.1.4 and Froala Inline Text Editor
CKEditor 5 Inline for GrapesJS v0.1.4 fixes Studio SDK toolbar clipping, iframe injection and link balloon bugs. Compare with Froala Inline — both $69.
Tutorial
Embed GrapesJS in Your SaaS: A Weekend Guide
Embed GrapesJS in your SaaS and ship a white-label page builder over a weekend. Honest tradeoffs, real code, and the plugins that close the UX gap.
Browse Plugin Categories
Jump directly to plugin category pages on the marketplace.